enhancements on changing permission
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@91619 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
2cd7f839b7
commit
42fbe82dfc
Binary file not shown.
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 831 B |
Binary file not shown.
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 989 B |
Binary file not shown.
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 953 B |
|
@ -201,4 +201,6 @@ public interface GWTWorkspaceService extends RemoteService{
|
|||
|
||||
String getMyLogin();
|
||||
|
||||
void setACLForVRE(String folderId, String aclType) throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
@ -179,4 +179,7 @@ public interface GWTWorkspaceServiceAsync {
|
|||
|
||||
void getMyLogin(AsyncCallback<String> callback);
|
||||
|
||||
void setACLForVRE(String folderId, String aclType,
|
||||
AsyncCallback<Void> callback);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,157 +0,0 @@
|
|||
package org.gcube.portlets.user.workspace.client.view.sharing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
|
||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
||||
import org.gcube.portlets.user.workspace.client.resources.Resources;
|
||||
import org.gcube.portlets.user.workspace.client.view.sharing.multisuggest.MultiValuePanel;
|
||||
import org.gcube.portlets.user.workspace.shared.WorkspaceACL;
|
||||
|
||||
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
||||
import com.extjs.gxt.ui.client.Style.Scroll;
|
||||
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
||||
import com.extjs.gxt.ui.client.event.SelectionListener;
|
||||
import com.extjs.gxt.ui.client.widget.Dialog;
|
||||
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
|
||||
/**
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
*/
|
||||
public class DialogPermission extends Dialog {
|
||||
|
||||
private int widthDialog = 530;
|
||||
private FileModel parentFolder = null;
|
||||
private UserStore userStore = new UserStore();
|
||||
private MultiValuePanel suggestPanel = new MultiValuePanel(userStore);
|
||||
private PanelPermission panelPermission;
|
||||
private DialogPermission INSTANCE = this;
|
||||
private List<InfoContactModel> listAlreadyShared = new ArrayList<InfoContactModel>(){
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Compare Login
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
|
||||
if(o==null)
|
||||
return false;
|
||||
|
||||
InfoContactModel contact = (InfoContactModel) o;
|
||||
|
||||
for (int i = 0; i < listAlreadyShared.size(); i++){
|
||||
if (contact.getName().compareTo(listAlreadyShared.get(i).getName())==0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
public FileModel getParentFolder() {
|
||||
return parentFolder;
|
||||
}
|
||||
|
||||
public void initLayout(String folderParentName){
|
||||
FormLayout layout = new FormLayout();
|
||||
layout.setLabelWidth(90);
|
||||
layout.setDefaultWidth(380);
|
||||
setLayout(layout);
|
||||
setModal(true);
|
||||
setScrollMode(Scroll.AUTOY);
|
||||
setBodyStyle("padding: 9px; background: none");
|
||||
setWidth(widthDialog);
|
||||
setHeight(200);
|
||||
setResizable(true);
|
||||
setButtonAlign(HorizontalAlignment.CENTER);
|
||||
setWidth(widthDialog);
|
||||
setButtons(Dialog.OKCANCEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use to create a new shared folder
|
||||
*/
|
||||
public DialogPermission(String folderParentName, HandlerManager eventBus) {
|
||||
|
||||
AppControllerExplorer.rpcWorkspaceService.getACLs(new AsyncCallback<List<WorkspaceACL>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<WorkspaceACL> result) {
|
||||
panelPermission = new PanelPermission(result);
|
||||
INSTANCE.layout(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
||||
INSTANCE.add(new Label("Error on recovering ACLs"));
|
||||
}
|
||||
});
|
||||
|
||||
initLayout(folderParentName);
|
||||
this.setIcon(Resources.getIconSharedFolder());
|
||||
setHeading("Set permission to folder: "+folderParentName);
|
||||
|
||||
setWidth(widthDialog);
|
||||
setButtons(Dialog.OKCANCEL);
|
||||
|
||||
add(panelPermission);
|
||||
addListners();
|
||||
}
|
||||
|
||||
public void addListners(){
|
||||
|
||||
this.getButtonById(Dialog.CANCEL).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
hide();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
this.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
if(isValidForm(false))
|
||||
hide();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param displayAlert
|
||||
* @return
|
||||
*/
|
||||
public boolean isValidForm(boolean displayAlert){
|
||||
|
||||
/*
|
||||
if(getSharedListUsers().size()==0){
|
||||
if(displayAlert)
|
||||
new MessageBoxAlert("Attention", "You must pick at least one user with which share the folder", null);
|
||||
suggestPanel.boxSetFocus();
|
||||
return false;
|
||||
}*/
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
|
@ -15,10 +15,13 @@ import org.gcube.portlets.user.workspace.shared.WorkspaceACL;
|
|||
|
||||
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
||||
import com.extjs.gxt.ui.client.Style.Scroll;
|
||||
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.Dialog;
|
||||
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
|
||||
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
||||
import com.extjs.gxt.ui.client.widget.VerticalPanel;
|
||||
import com.extjs.gxt.ui.client.widget.form.TextArea;
|
||||
import com.extjs.gxt.ui.client.widget.form.TextField;
|
||||
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
|
||||
|
@ -46,8 +49,9 @@ public class DialogShareFolder extends Dialog {
|
|||
private MultiValuePanel suggestPanel = new MultiValuePanel(userStore);
|
||||
private Button buttonMultiDrag = new Button("Choose Contacts");
|
||||
private TextField<String> txtOwner;
|
||||
private PanelPermission permission;
|
||||
|
||||
private PanelTogglePermission permission;
|
||||
private HorizontalPanel vpPermission = null;
|
||||
|
||||
private List<InfoContactModel> listAlreadyShared = new ArrayList<InfoContactModel>(){
|
||||
|
||||
/**
|
||||
|
@ -138,33 +142,44 @@ public class DialogShareFolder extends Dialog {
|
|||
flexTable.setWidget(2, 0, labelDescription);
|
||||
flexTable.setWidget(2, 1, textAreaDescription);
|
||||
|
||||
|
||||
|
||||
if(!folder.isShared()){ //SETTABLE PERMISSION ONLY IF FOLDER IS NOT ALREADY SHARED
|
||||
vpPermission = new HorizontalPanel();
|
||||
vpPermission.setVerticalAlign(VerticalAlignment.MIDDLE);
|
||||
Label labelProperty = new Label("Permissions");
|
||||
// final ToggleButton togglePermission = new ToggleButton("Set Permissions");
|
||||
flexTable.setWidget(3, 0, labelProperty);
|
||||
// final ToggleButton togglePermission = new ToggleButton("Set Permissions");
|
||||
// flexTable.setWidget(3, 0, labelProperty);
|
||||
|
||||
flexTable.setWidget(3, 1, Resources.getIconLoading().createImage());
|
||||
// flexTable.setWidget(3, 1, Resources.getIconLoading().createImage());
|
||||
vpPermission.add(labelProperty);
|
||||
|
||||
AppControllerExplorer.rpcWorkspaceService.getACLs(new AsyncCallback<List<WorkspaceACL>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<WorkspaceACL> result) {
|
||||
permission = new PanelPermission(result);
|
||||
flexTable.setWidget(3, 1, permission);
|
||||
lc.layout();
|
||||
permission = new PanelTogglePermission(result);
|
||||
// flexTable.setWidget(3, 1, permission);
|
||||
// lc.layout();
|
||||
vpPermission.add(permission);
|
||||
vpPermission.layout();
|
||||
layout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
||||
flexTable.setWidget(3, 1, new Label("Error on recovering ACLs"));
|
||||
// flexTable.setWidget(3, 1, new Label("Error on recovering ACLs"));
|
||||
|
||||
vpPermission.add(new Label("Error on recovering ACLs"));
|
||||
vpPermission.layout();
|
||||
layout();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
lc.add(flexTable);
|
||||
|
||||
if(vpPermission!=null)
|
||||
lc.add(vpPermission);
|
||||
lc.mask();
|
||||
userStore.getListSharedUserByFolderId(folder.getIdentifier(), new AsyncCallback<List<InfoContactModel>>() {
|
||||
|
||||
|
@ -301,34 +316,45 @@ public class DialogShareFolder extends Dialog {
|
|||
flexTable.setWidget(2, 1, textAreaDescription);
|
||||
|
||||
|
||||
vpPermission = new HorizontalPanel();
|
||||
vpPermission.setVerticalAlign(VerticalAlignment.MIDDLE);
|
||||
Label labelProperty = new Label("Permissions");
|
||||
// final ToggleButton togglePermission = new ToggleButton("Set Permissions");
|
||||
flexTable.setWidget(3, 0, labelProperty);
|
||||
// flexTable.setWidget(3, 0, labelProperty);
|
||||
|
||||
flexTable.setWidget(3, 1, Resources.getIconLoading().createImage());
|
||||
// flexTable.setWidget(3, 1, Resources.getIconLoading().createImage());
|
||||
vpPermission.add(labelProperty);
|
||||
|
||||
AppControllerExplorer.rpcWorkspaceService.getACLs(new AsyncCallback<List<WorkspaceACL>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<WorkspaceACL> result) {
|
||||
permission = new PanelPermission(result);
|
||||
flexTable.setWidget(3, 1, permission);
|
||||
lc.layout();
|
||||
permission = new PanelTogglePermission(result);
|
||||
// flexTable.setWidget(3, 1, permission);
|
||||
// lc.layout();
|
||||
vpPermission.add(permission);
|
||||
vpPermission.layout();
|
||||
layout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
||||
flexTable.setWidget(3, 1, new Label("Error on recovering ACLs"));
|
||||
// flexTable.setWidget(3, 1, new Label("Error on recovering ACLs"));
|
||||
|
||||
vpPermission.add(new Label("Error on recovering ACLs"));
|
||||
vpPermission.layout();
|
||||
layout();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
lc.add(flexTable);
|
||||
|
||||
|
||||
setFocusWidget(txtName);
|
||||
add(txtName);
|
||||
add(lc);
|
||||
|
||||
addListners();
|
||||
|
||||
this.show();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.gcube.portlets.user.workspace.client.view.sharing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.workspace.client.resources.Resources;
|
||||
|
@ -8,6 +9,7 @@ import org.gcube.portlets.user.workspace.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;
|
||||
|
@ -27,38 +29,38 @@ public class PanelTogglePermission extends LayoutContainer {
|
|||
|
||||
public PanelTogglePermission(List<WorkspaceACL> acls) {
|
||||
|
||||
setStyleAttribute("margin-top", "10px");
|
||||
setStyleAttribute("margin-bottom", "10px");
|
||||
setSize(350, 30);
|
||||
// setStyleAttribute("margin-top", "10px");
|
||||
setStyleAttribute("margin-bottom", "15px");
|
||||
setSize(350, 40);
|
||||
|
||||
// buttonGroup = new ButtonGroup(acls.size());
|
||||
|
||||
// buttonGroup.mask("Loading ACLs");
|
||||
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", "5px");
|
||||
toggle.setStyleAttribute("margin-right", "10px");
|
||||
// buttonGroup.add(toggle);
|
||||
// listToogle.add(toggle);
|
||||
// add(toggle);
|
||||
hp.add(toggle);
|
||||
}
|
||||
}
|
||||
|
||||
hp.unmask();
|
||||
// buttonGroup.unmask();
|
||||
add(hp);
|
||||
layout();
|
||||
}
|
||||
|
||||
private ToggleButton createToggle(final WorkspaceACL acl) {
|
||||
|
||||
final ToggleButton bToggle = new ToggleButton(acl.getLabel());
|
||||
bToggle.setScale(ButtonScale.LARGE);
|
||||
bToggle.setScale(ButtonScale.MEDIUM);
|
||||
bToggle.setId(acl.getId());
|
||||
bToggle.toggle(acl.getDefaultValue());
|
||||
bToggle.setIconAlign(IconAlign.BOTTOM);
|
||||
bToggle.setIconAlign(IconAlign.TOP);
|
||||
bToggle.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
package org.gcube.portlets.user.workspace.client.view.sharing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.dom.client.HasClickHandlers;
|
||||
import com.google.gwt.event.shared.HandlerRegistration;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.HasWidgets;
|
||||
import com.google.gwt.user.client.ui.Panel;
|
||||
import com.google.gwt.user.client.ui.ToggleButton;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author francesco
|
||||
*
|
||||
*/
|
||||
public class ToggleButtonPanel extends Composite implements HasWidgets, HasClickHandlers {
|
||||
|
||||
private List<ClickHandler> handlers = new ArrayList<ClickHandler>();
|
||||
private final Panel panel;
|
||||
|
||||
public ToggleButtonPanel() {
|
||||
this(new VerticalPanel());
|
||||
}
|
||||
|
||||
public ToggleButtonPanel(Panel panel) {
|
||||
this.panel = panel;
|
||||
initWidget(panel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(Widget w) {
|
||||
if (w instanceof ToggleButton) {
|
||||
ToggleButton button = (ToggleButton) w;
|
||||
button.addClickHandler(handler);
|
||||
}
|
||||
panel.add(w);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
panel.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Widget> iterator() {
|
||||
return panel.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Widget w) {
|
||||
return panel.remove(w);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWidth(String width) {
|
||||
panel.setWidth(width);
|
||||
};
|
||||
|
||||
@Override
|
||||
public void setHeight(String height) {
|
||||
panel.setHeight(height);
|
||||
}
|
||||
|
||||
|
||||
private ClickHandler handler = new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Iterator<Widget> itr = panel.iterator();
|
||||
while (itr.hasNext()) {
|
||||
Widget w = itr.next();
|
||||
if (w instanceof ToggleButton) {
|
||||
ToggleButton button = (ToggleButton) w;
|
||||
button.setDown(false);
|
||||
if (event.getSource().equals(button)) {
|
||||
button.setDown(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ClickHandler h : handlers) {
|
||||
h.onClick(event);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public HandlerRegistration addClickHandler(final ClickHandler handler) {
|
||||
handlers.add(handler);
|
||||
return new HandlerRegistration() {
|
||||
|
||||
@Override
|
||||
public void removeHandler() {
|
||||
handlers.remove(handler);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public ToggleButton getDown(){
|
||||
|
||||
Iterator<Widget> it = iterator();
|
||||
while (it!=null && it.hasNext()) {
|
||||
Widget w = (Widget) it.next();
|
||||
if (w instanceof ToggleButton) {
|
||||
ToggleButton t = (ToggleButton) w;
|
||||
if(t.isDown())
|
||||
return t;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -2553,4 +2553,41 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
ASLSession asl = WsUtil.getAslSession(this.getThreadLocalRequest().getSession());
|
||||
return asl.getUsername();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param folderId
|
||||
* @param listUserIds
|
||||
* @param aclType
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void setACLForVRE(String folderId, String aclType) throws Exception{
|
||||
try {
|
||||
|
||||
if(folderId == null)
|
||||
throw new Exception("Folder id is null");
|
||||
|
||||
List<String> listLogins = new ArrayList<String>();
|
||||
listLogins.add(getMyLogin());
|
||||
|
||||
workspaceLogger.trace("Setting ACL for VRE FOLDER id: "+folderId);
|
||||
workspaceLogger.trace("ACL type is: "+aclType);
|
||||
|
||||
Workspace workspace = getWorkspace();
|
||||
WorkspaceItem wsItem = workspace.getItem(folderId);
|
||||
|
||||
if(wsItem.isShared() && (wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER))){
|
||||
WorkspaceSharedFolder ite = (WorkspaceSharedFolder) workspace.getItemByPath(wsItem.getPath());
|
||||
ite.setACL(listLogins, ACLType.valueOf(aclType));
|
||||
}else
|
||||
throw new Exception("Source item is not shared or shared folder");
|
||||
|
||||
workspaceLogger.trace("Setting ACL completed, retuning");
|
||||
} catch (Exception e) {
|
||||
workspaceLogger.error("Error in set ACLs", e);
|
||||
String error = ConstantsExplorer.SERVER_ERROR +" setting permissions. "+e.getMessage();
|
||||
throw new Exception(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue