ref 13226:StorageHub - Update workspace-sharing-widget to SH
https://support.d4science.org/issues/13226 Updated to StorageHub git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-sharing-widget@177215 82a268e6-3cf1-43bd-a215-b396298e98cfmaster
parent
da0f424536
commit
b9d5ac9622
@ -0,0 +1,96 @@
|
||||
package org.gcube.portlets.widgets.workspacesharingwidget.client;
|
||||
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.client.resources.Resources;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest.MultiDragContact;
|
||||
|
||||
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.Html;
|
||||
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
||||
import com.google.gwt.core.shared.GWT;
|
||||
import com.google.gwt.user.client.Random;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
public class ShowPermissionsDialog extends Dialog {
|
||||
|
||||
private static final int HEIGHT_DIALOG = 300;
|
||||
private static final int WIDTH_DIALOG = 600;
|
||||
private String headTitle;
|
||||
private String itemId;
|
||||
private Html htmlCurrentPermissions;
|
||||
|
||||
public ShowPermissionsDialog(String headTitle, String itemId) {
|
||||
this.headTitle = headTitle;
|
||||
this.itemId = itemId;
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setId(ShowPermissionsDialog.class.getName() + Random.nextInt());
|
||||
setSize(WIDTH_DIALOG, HEIGHT_DIALOG);
|
||||
setResizable(false);
|
||||
setMaximizable(false);
|
||||
setIcon(Resources.getIconUsers());
|
||||
setModal(true);
|
||||
setHeading(headTitle);
|
||||
|
||||
setButtonAlign(HorizontalAlignment.CENTER);
|
||||
setButtons(Dialog.OKCANCEL);
|
||||
|
||||
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) {
|
||||
hide();
|
||||
}
|
||||
});
|
||||
|
||||
createCurrentPermissionPanel();
|
||||
|
||||
}
|
||||
|
||||
void createCurrentPermissionPanel() {
|
||||
htmlCurrentPermissions = new Html();
|
||||
|
||||
LayoutContainer lcCurrentPermissions = new LayoutContainer();
|
||||
htmlCurrentPermissions.setWidth(MultiDragContact.WIDTH_CP);
|
||||
htmlCurrentPermissions.setStyleAttribute("padding", MultiDragContact.PADDING + "px");
|
||||
lcCurrentPermissions.setScrollMode(Scroll.AUTOY);
|
||||
lcCurrentPermissions.setHeight(50);
|
||||
lcCurrentPermissions.add(htmlCurrentPermissions);
|
||||
|
||||
WorkspaceSharingController.rpcWorkspaceSharingService.getACLsDescriptionForSharedFolderId(itemId,
|
||||
new AsyncCallback<String>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
GWT.log("error getACLsDescriptionForSharedFolderId: " + caught.getMessage(), caught);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
String msg = "#<b>Current Permissions:</b> <br/>";
|
||||
msg += result;
|
||||
htmlCurrentPermissions.setHtml(msg);
|
||||
}
|
||||
});
|
||||
add(lcCurrentPermissions);
|
||||
|
||||
}
|
||||
|
||||
public String getHeadTitle() {
|
||||
return headTitle;
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,26 @@
|
||||
package org.gcube.portlets.widgets.workspacesharingwidget.server.notifications;
|
||||
|
||||
import org.gcube.applicationsupportlayer.social.shared.SocialFileItem;
|
||||
import org.gcube.applicationsupportlayer.social.shared.SocialSharedFolder;
|
||||
import org.gcube.common.storagehub.model.items.FolderItem;
|
||||
import org.gcube.common.storagehub.model.items.Item;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
*
|
||||
*/
|
||||
public class SocialItemFactory {
|
||||
|
||||
public SocialFileItem createSocialFileItem(Item item, FolderItem parent) {
|
||||
SocialSharedFolder socialSharedFolder=createSocialSharedFolder(parent);
|
||||
return new SocialFileItem(item.getId(), item.getName(), item.getTitle(), item.getPath(), socialSharedFolder);
|
||||
}
|
||||
|
||||
public SocialSharedFolder createSocialSharedFolder(FolderItem folder) {
|
||||
return new SocialSharedFolder(folder.getId(), folder.getName(), folder.getTitle(), folder.getName(),
|
||||
folder.getPath(), folder.getParentId(), false);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.widgets.workspacesharingwidget.server.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.storagehub.model.acls.AccessType;
|
||||
|
||||
/**
|
||||
* The Class AclTypeComparator.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapaATisti.cnr.it Mar 5, 2015
|
||||
*/
|
||||
public class AccessTypeComparator implements Comparator<AccessType> {
|
||||
|
||||
public static final Map<AccessType, Integer> aclTypeOrder;
|
||||
static {
|
||||
aclTypeOrder = new LinkedHashMap<AccessType, Integer>();
|
||||
aclTypeOrder.put(AccessType.READ_ONLY, 0);
|
||||
aclTypeOrder.put(AccessType.WRITE_OWNER, 1);
|
||||
aclTypeOrder.put(AccessType.WRITE_ALL, 2);
|
||||
// aclTypeOrder.put(ACLType.ADMINISTRATOR, 3);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public int compare(AccessType o1, AccessType o2) {
|
||||
if (o1 == null)
|
||||
return -1;
|
||||
if (o2 == null)
|
||||
return 1;
|
||||
|
||||
Integer order1 = aclTypeOrder.get(o1);
|
||||
Integer order2 = aclTypeOrder.get(o2);
|
||||
|
||||
if (order1 == null)
|
||||
return -1;
|
||||
|
||||
if (order2 == null)
|
||||
return 1;
|
||||
|
||||
if (order1 == order2)
|
||||
return 0;
|
||||
|
||||
return order1 < order2 ? -1 : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the allowed.
|
||||
*
|
||||
* @param accessType
|
||||
* the acl type to compare
|
||||
* @param includeEqual
|
||||
* if true include equal ACLType, no otherwise
|
||||
* @return the allowed
|
||||
*/
|
||||
public List<AccessType> getAllowed(AccessType accessType, boolean includeEqual) {
|
||||
|
||||
List<AccessType> allowed = new ArrayList<>();
|
||||
|
||||
if (accessType == null)
|
||||
return allowed;
|
||||
|
||||
// IF MAP DOES NOT CONTAINS ACT TYPE IT IS NOT COMPARABLE
|
||||
if (aclTypeOrder.get(accessType) == null)
|
||||
return allowed;
|
||||
|
||||
for (AccessType aMap : aclTypeOrder.keySet()) {
|
||||
int comparator = compare(aMap, accessType);
|
||||
if (comparator == 1)
|
||||
allowed.add(aMap);
|
||||
else if (includeEqual && comparator == 0)
|
||||
allowed.add(aMap);
|
||||
}
|
||||
|
||||
return allowed;
|
||||
}
|
||||
|
||||
/**
|
||||
* The main method.
|
||||
*
|
||||
* @param args
|
||||
* the arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
AccessTypeComparator comparator = new AccessTypeComparator();
|
||||
|
||||
List<AccessType> allowed = comparator.getAllowed(AccessType.WRITE_ALL, false);
|
||||
|
||||
System.out.println(allowed);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,123 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.widgets.workspacesharingwidget.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapaATisti.cnr.it Nov 29, 2016
|
||||
*/
|
||||
public class AllowAccess implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -2180345568585856822L;
|
||||
|
||||
private String itemId;
|
||||
private Boolean accessGranted = false;
|
||||
private String accessAllowDenyMotivation;
|
||||
private String error;
|
||||
|
||||
public AllowAccess() {
|
||||
}
|
||||
|
||||
public AllowAccess(String itemId) {
|
||||
|
||||
}
|
||||
|
||||
public AllowAccess(String itemId, Boolean accessGranted, String accessAllowDenyMotivation, String error) {
|
||||
|
||||
super();
|
||||
this.itemId = itemId;
|
||||
this.accessGranted = accessGranted;
|
||||
this.accessAllowDenyMotivation = accessAllowDenyMotivation;
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
public String getItemId() {
|
||||
|
||||
return itemId;
|
||||
}
|
||||
|
||||
public Boolean getAccessGranted() {
|
||||
|
||||
return accessGranted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the accessAllowDenyMotivation
|
||||
*/
|
||||
public String getAccessAllowDenyMotivation() {
|
||||
|
||||
return accessAllowDenyMotivation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the error
|
||||
*/
|
||||
public String getError() {
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param itemId
|
||||
* the itemId to set
|
||||
*/
|
||||
public void setItemId(String itemId) {
|
||||
|
||||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param accessGranted
|
||||
* the accessGranted to set
|
||||
*/
|
||||
public void setAccessGranted(Boolean accessGranted) {
|
||||
|
||||
this.accessGranted = accessGranted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param accessAllowDenyMotivation
|
||||
* the accessAllowDenyMotivation to set
|
||||
*/
|
||||
public void setAccessAllowDenyMotivation(String accessAllowDenyMotivation) {
|
||||
|
||||
this.accessAllowDenyMotivation = accessAllowDenyMotivation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param error
|
||||
* the error to set
|
||||
*/
|
||||
public void setError(String error) {
|
||||
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("AllowAccess [itemId=");
|
||||
builder.append(itemId);
|
||||
builder.append(", accessGranted=");
|
||||
builder.append(accessGranted);
|
||||
builder.append(", accessAllowDenyMotivation=");
|
||||
builder.append(accessAllowDenyMotivation);
|
||||
builder.append(", error=");
|
||||
builder.append(error);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package org.gcube.portlets.widgets.workspacesharingwidget.shared;
|
||||
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.ACL_TYPE;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapaATisti.cnr.it Feb 21, 2014
|
||||
*
|
||||
*/
|
||||
public class ExtendedWorkspaceACL extends WorkspaceACL {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 5272059977475806564L;
|
||||
|
||||
private String loginOwner;
|
||||
private String workspaceItemId;
|
||||
|
||||
private boolean isBaseSharedFolder;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ExtendedWorkspaceACL() {
|
||||
}
|
||||
|
||||
public ExtendedWorkspaceACL(String id, ACL_TYPE aclType, String label, boolean defaultValue, USER_TYPE userType,
|
||||
String description, String loginOwner, String workspaceItemId, boolean isBaseSharedFolder) {
|
||||
super(id, aclType, label, defaultValue, userType, description);
|
||||
this.loginOwner = loginOwner;
|
||||
this.workspaceItemId = workspaceItemId;
|
||||
this.isBaseSharedFolder = isBaseSharedFolder;
|
||||
}
|
||||
|
||||
public String getLoginOwner() {
|
||||
return loginOwner;
|
||||
}
|
||||
|
||||
public String getWorkspaceItemId() {
|
||||
return workspaceItemId;
|
||||
}
|
||||
|
||||
public void setLoginOwner(String loginOwner) {
|
||||
this.loginOwner = loginOwner;
|
||||
}
|
||||
|
||||
public void setWorkspaceItemId(String workspaceItemId) {
|
||||
this.workspaceItemId = workspaceItemId;
|
||||
}
|
||||
|
||||
public boolean isBaseSharedFolder() {
|
||||
return isBaseSharedFolder;
|
||||
}
|
||||
|
||||
public void setBaseSharedFolder(boolean isBaseSharedFolder) {
|
||||
this.isBaseSharedFolder = isBaseSharedFolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ExtendedWorkspaceACL [loginOwner=" + loginOwner + ", workspaceItemId=" + workspaceItemId
|
||||
+ ", isBaseSharedFolder=" + isBaseSharedFolder + ", getId()=" + getId() + ", getLabel()=" + getLabel()
|
||||
+ ", getDefaultValue()=" + getDefaultValue() + ", getUserType()=" + getUserType()
|
||||
+ ", getDescription()=" + getDescription() + ", getAclType()=" + getAclType() + "]";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.widgets.workspacesharingwidget.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapaATisti.cnr.it
|
||||
* Mar 6, 2015
|
||||
*/
|
||||
public class ReportAssignmentACL implements Serializable{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7218122043660957432L;
|
||||
|
||||
private List<String> validLogins;
|
||||
private List<String> errors;
|
||||
private String aclType;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ReportAssignmentACL() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the validLogins
|
||||
*/
|
||||
public List<String> getValidLogins() {
|
||||
return validLogins;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param validLogins the validLogins to set
|
||||
*/
|
||||
public void setValidLogins(List<String> validLogins) {
|
||||
this.validLogins = validLogins;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the errors
|
||||
*/
|
||||
public List<String> getErrors() {
|
||||
return errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param errors the errors to set
|
||||
*/
|
||||
public void setErrors(List<String> errors) {
|
||||
this.errors = errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the aclType
|
||||
*/
|
||||
public String getAclType() {
|
||||
return aclType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param aclType the aclType to set
|
||||
*/
|
||||
public void setAclType(String aclType) {
|
||||
this.aclType = aclType;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ReportValidationACL [validLogins=");
|
||||
builder.append(validLogins);
|
||||
builder.append(", errors=");
|
||||
builder.append(errors);
|
||||
builder.append(", aclType=");
|
||||
builder.append(aclType);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue