enhancements

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-sharing-widget@92271 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2014-02-25 14:58:42 +00:00
parent 8e425fd3e9
commit 1ac65af1eb
44 changed files with 4136 additions and 6 deletions

View File

@ -0,0 +1,16 @@
/**
*
*/
package org.gcube.portlets.widgets.workspacesharingwidget.client;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @Feb 25, 2014
*
*/
public interface ConstantsSharing {
public static final String LOADINGSTYLE = "x-mask-loading";
public static final String SERVER_ERROR = "Sorry, an error has occurred on the server when";
public static final String TRY_AGAIN = "Try again";
}

View File

@ -7,14 +7,37 @@ import org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSha
import org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingServiceAsync;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @Feb 25, 2014
*
*
*/
public class WorkspaceSharingController {
public static final WorkspaceSharingServiceAsync rpcWorkspaceService = (WorkspaceSharingServiceAsync) GWT.create(WorkspaceSharingService.class);
public static final WorkspaceSharingServiceAsync rpcWorkspaceSharingService = (WorkspaceSharingServiceAsync) GWT
.create(WorkspaceSharingService.class);
public static String myLogin;
private void loadMyLogin() {
rpcWorkspaceSharingService.getMyLogin(new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
GWT.log("Error on loading my login is empty");
myLogin = "";
}
@Override
public void onSuccess(String result) {
GWT.log("My login is: " + result);
myLogin = result;
}
});
}
}

View File

@ -19,7 +19,7 @@ public class WorkspaceSharingWidget implements EntryPoint {
final Label loading = new Label("loading");
WorkspaceSharingController.rpcWorkspaceService.greetServer("a",new AsyncCallback<String>() {
WorkspaceSharingController.rpcWorkspaceSharingService.greetServer("a",new AsyncCallback<String>() {
@Override
public void onSuccess(String result) {

View File

@ -0,0 +1,38 @@
/**
*
*/
package org.gcube.portlets.widgets.workspacesharingwidget.client.resources;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @Feb 25, 2014
*
*/
public class GetPermissionIconByACL {
public static AbstractImagePrototype getImage(WorkspaceACL acl) {
if(acl==null || acl.getId()==null)
return null;
String id = acl.getId();
if (id.compareTo("ADMINISTRATOR") == 0) {
return Resources.getIconAdministrator();
} else if (id.compareTo("READ_ONLY") == 0) {
return Resources.getIconReadOnly();
} else if (id.compareTo("WRITE_OWNER") == 0) {
return Resources.getIconWriteOwn();
} else if (id.compareTo("WRITE_ALL") == 0) {
return Resources.getIconWriteAll();
}
return null;
}
}

View File

@ -0,0 +1,26 @@
package org.gcube.portlets.widgets.workspacesharingwidget.client.resources;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ImageResource;
public interface Icons extends ClientBundle {
@Source("readonly.png")
ImageResource readonly();
@Source("writeown.png")
ImageResource writeown();
@Source("writeall.png")
ImageResource writeall();
@Source("admin.png")
ImageResource administrator();
@Source("users.png")
ImageResource users();
@Source("info-icon.png")
ImageResource info();
}

View File

@ -0,0 +1,42 @@
package org.gcube.portlets.widgets.workspacesharingwidget.client.resources;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @Feb 25, 2014
*
*/
public class Resources {
public static final Icons ICONS = GWT.create(Icons.class);
public static AbstractImagePrototype getIconWriteOwn() {
return AbstractImagePrototype.create(ICONS.writeown());
}
public static AbstractImagePrototype getIconWriteAll() {
return AbstractImagePrototype.create(ICONS.writeall());
}
public static AbstractImagePrototype getIconReadOnly() {
return AbstractImagePrototype.create(ICONS.readonly());
}
public static AbstractImagePrototype getIconAdministrator() {
return AbstractImagePrototype.create(ICONS.administrator());
}
public static AbstractImagePrototype getIconUsers() {
return AbstractImagePrototype.create(ICONS.users());
}
public static AbstractImagePrototype getIconInfo() {
return AbstractImagePrototype.create(ICONS.info());
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -1,5 +1,10 @@
package org.gcube.portlets.widgets.workspacesharingwidget.client.rpc;
import java.util.List;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@ -8,5 +13,37 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
*/
@RemoteServiceRelativePath("workspacesharing")
public interface WorkspaceSharingService extends RemoteService {
String greetServer(String name) throws IllegalArgumentException;
String greetServer(String name) throws IllegalArgumentException;
/**
* @return
* @throws Exception
*/
List<InfoContactModel> getAllContacts() throws Exception;
/**
* @param folderSharedId
* @return
* @throws Exception
*/
List<InfoContactModel> getListUserSharedByFolderSharedId(
String folderSharedId) throws Exception;
/**
* @param itemId
* @return
* @throws Exception
*/
InfoContactModel getOwnerByItemId(String itemId) throws Exception;
/**
* @return
* @throws Exception
*/
List<WorkspaceACL> getACLs() throws Exception;
/**
* @return
*/
String getMyLogin();
}

View File

@ -1,8 +1,12 @@
package org.gcube.portlets.widgets.workspacesharingwidget.client.rpc;
import java.util.List;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
public interface WorkspaceSharingServiceAsync
{
@ -35,4 +39,21 @@ public interface WorkspaceSharingServiceAsync
// Utility class should not be instanciated
}
}
void getAllContacts(AsyncCallback<List<InfoContactModel>> callback);
void getListUserSharedByFolderSharedId(String folderSharedId,
AsyncCallback<List<InfoContactModel>> callback);
void getOwnerByItemId(String itemId,
AsyncCallback<InfoContactModel> callback);
void getACLs(AsyncCallback<List<WorkspaceACL>> callback);
void getMyLogin(AsyncCallback<String> callback);
}

View File

@ -0,0 +1,16 @@
package org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing;
import java.util.List;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
import com.google.gwt.user.client.rpc.AsyncCallback;
public interface ContactFetcher {
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

@ -0,0 +1,414 @@
package org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.widgets.workspacesharingwidget.client.WorkspaceSharingController;
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest.MultiDragContact;
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest.MultiValuePanel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.FileModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
import org.gcube.portlets.widgets.workspacesharingwidget.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.MessageBox;
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;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Label;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*
*/
public class DialogShareFolder extends Dialog {
private int widthDialog = 530;
private int heightTextArea = 100;
private TextField<String> txtName;
private TextArea textAreaDescription = new TextArea();
private FileModel parentFolder = null;
private UserStore userStore = new UserStore();
private MultiValuePanel suggestPanel = new MultiValuePanel(userStore);
private Button buttonMultiDrag = new Button("Choose Contacts");
private TextField<String> txtOwner;
private PanelTogglePermission permission;
private HorizontalPanel hpPermission = null;
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;
};
};
/**
* Use to modify a shared folder or share an existing folder
* @param folder
* @param type
*/
public DialogShareFolder(String folderParentName, FileModel folder, HandlerManager eventBus) {
initLayout(folderParentName);
this.parentFolder = folder;
// this.setIcon(Resources.getIconShareFolder());
setWidth(widthDialog);
setButtons(Dialog.OKCANCEL);
setHeading("Share folder: "+folder.getName());
txtName = new TextField<String>();
txtName.setAllowBlank(false);
txtName.setValue(folder.getName());
txtName.setReadOnly(true);
txtName.setAutoValidate(true);
txtName.setFieldLabel("Folder Name");
txtOwner = new TextField<String>();
txtOwner.setAllowBlank(true);
txtOwner.setValue("");
txtOwner.setReadOnly(true);
txtOwner.setAutoValidate(false);
txtOwner.setFieldLabel("Owner");
textAreaDescription.setFieldLabel("Description");
textAreaDescription.setHeight(heightTextArea);
textAreaDescription.setWidth(380);
textAreaDescription.setValue(folder.getDescription());
// textAreaDescription.setReadOnly(true);
final LayoutContainer lc = new LayoutContainer();
lc.setStyleAttribute("margin-top", "10px");
lc.setStyleAttribute("margin-bottom", "10px");
lc.setSize(480, 50);
final FlexTable flexTable = new FlexTable();
flexTable.setStyleName("userssuggest");
Label labelShareWith = new Label("Share with users");
flexTable.setWidget(0, 0, labelShareWith);
flexTable.setWidget(0, 1, suggestPanel);
buttonMultiDrag.setStyleName("wizardButton");
// buttonMultiDrag.setIcon(Resources.getIconUsers());
flexTable.setWidget(1, 0, new Label("Add more"));
flexTable.setWidget(1, 1, buttonMultiDrag);
Label labelDescription = new Label("Description");
flexTable.setWidget(2, 0, labelDescription);
flexTable.setWidget(2, 1, textAreaDescription);
// if(!folder.isShared()){ //SETTABLE PERMISSION ONLY IF FOLDER IS NOT ALREADY SHARED
hpPermission = new HorizontalPanel();
hpPermission.setVerticalAlign(VerticalAlignment.MIDDLE);
Label labelProperty = new Label("Permissions");
// final ToggleButton togglePermission = new ToggleButton("Set Permissions");
// flexTable.setWidget(3, 0, labelProperty);
// flexTable.setWidget(3, 1, Resources.getIconLoading().createImage());
hpPermission.add(labelProperty);
WorkspaceSharingController.rpcWorkspaceSharingService.getACLs(new AsyncCallback<List<WorkspaceACL>>() {
@Override
public void onSuccess(List<WorkspaceACL> result) {
permission = new PanelTogglePermission(result);
hpPermission.add(permission);
hpPermission.layout();
layout();
}
@Override
public void onFailure(Throwable caught) {
hpPermission.add(new Label("Error on recovering ACLs"));
hpPermission.layout();
layout();
}
});
// }
lc.add(flexTable);
if(hpPermission!=null)
lc.add(hpPermission);
lc.mask();
userStore.getListSharedUserByFolderId(folder.getIdentifier(), new AsyncCallback<List<InfoContactModel>>() {
@Override
public void onSuccess(List<InfoContactModel> result) {
for (InfoContactModel infoContactModel : result) {
if(infoContactModel.getName()!=null){
listAlreadyShared.add(infoContactModel);
suggestPanel.addRecipient(infoContactModel.getName(),false);
}
}
lc.unmask();
}
@Override
public void onFailure(Throwable caught) {
lc.unmask();
}
});
userStore.getOwner(folder.getIdentifier(), new AsyncCallback<InfoContactModel>() {
@Override
public void onFailure(Throwable caught) {
txtOwner.setValue("Error on retrieving Owner");
}
@Override
public void onSuccess(InfoContactModel result) {
txtOwner.setValue(result.getName());
permissionControl(result.getLogin(), true);
}
});
setFocusWidget(suggestPanel.getBox());
add(txtName);
add(txtOwner);
add(lc);
addListners();
enableFormDialog(false); //FORM IS DISABLED BY DEFAULT
this.show();
}
private void permissionControl(String owner, boolean showAlert){
GWT.log("Permission control compare between owner: "+owner +" and my login: "+WorkspaceSharingController.myLogin);
if(WorkspaceSharingController.myLogin.compareToIgnoreCase(owner)!=0){
enableFormDialog(false);
if(showAlert)
MessageBox.alert("Permission denied", "You have no permissions to change sharing. You are not owner of \""+txtName.getValue()+"\"", null);
}else{
enableFormDialog(true);
}
}
private void enableFormDialog(boolean bool){
getButtonById(Dialog.OK).setEnabled(bool);
buttonMultiDrag.setEnabled(bool);
textAreaDescription.setEnabled(bool);
if(permission!=null)
permission.setEnabled(bool);
// setEnabled(bool);
}
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(397);
setResizable(true);
setButtonAlign(HorizontalAlignment.CENTER);
setWidth(widthDialog);
setButtons(Dialog.OKCANCEL);
}
public List<InfoContactModel> getSharedListUsers() {
// printSelectedUser();
return suggestPanel.getSelectedUser();
}
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();
}
});
buttonMultiDrag.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final MultiDragContact multiDrag = new MultiDragContact();
multiDrag.show();
List<InfoContactModel> exclusiveContacts = userStore.getExclusiveContactsFromAllContact(suggestPanel.getSelectedUser());
multiDrag.addSourceContacts(exclusiveContacts);
for (InfoContactModel infoContactModel : suggestPanel.getSelectedUser()) {
if(!listAlreadyShared.contains(infoContactModel))
multiDrag.addTargetContact(infoContactModel);
}
multiDrag.addAlreadySharedContacts(suggestPanel.getSelectedUser());
// multiDrag.addTargetContacts(suggestPanel.getSelectedUser());
multiDrag.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
initSuggestContacts();
for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
suggestPanel.addRecipient(infoContactModel.getName(),true);
}
// for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
//
// if(!listAlreadySharedContains(infoContactModel))
// suggestPanel.addRecipient(infoContactModel.getName(),true);
// }
suggestPanel.boxSetFocus();
// printSelectedUser();
}
});
}
});
}
private boolean listAlreadySharedContains(InfoContactModel contact){
if(contact==null)
return false;
for (InfoContactModel ct : listAlreadyShared) {
if(ct.getLogin().compareTo(contact.getLogin())==0){
return true;
}
}
return false;
}
//DEBUG
private void printSelectedUser(){
System.out.println("SELETECTED USERS: ");
for (InfoContactModel contact : suggestPanel.getSelectedUser())
System.out.println(contact);
}
private void initSuggestContacts(){
suggestPanel.resetItemSelected();
for (InfoContactModel contact : listAlreadyShared) {
suggestPanel.addRecipient(contact.getName(), false);
}
}
public String getName() {
return txtName.getValue();
}
public String getDescription() {
if(textAreaDescription.getValue()==null)
return "";
return textAreaDescription.getValue();
}
/**
*
* @param displayAlert
* @return
*/
public boolean isValidForm(boolean displayAlert){
if(!txtName.isValid()){
if(displayAlert)
MessageBox.alert("Attention", "Name must not be empty", null);
txtName.focus();
return false;
}
if(getSharedListUsers().size()==0){
if(displayAlert)
MessageBox.alert("Attention", "You must pick at least one user with which share the folder", null);
suggestPanel.boxSetFocus();
return false;
}
return true;
}
public WorkspaceACL getSelectedACL(){
if(permission!=null)
return permission.getSelectedACL();
return null;
}
}

View File

@ -0,0 +1,59 @@
package org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing;
import java.util.List;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL.USER_TYPE;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.form.Radio;
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
import com.extjs.gxt.ui.client.widget.tips.ToolTipConfig;
public class PanelPermission extends LayoutContainer {
protected static final String WORKSPACEACL = "WORKSPACEACL";
private RadioGroup radioGroup = new RadioGroup();
public PanelPermission(List<WorkspaceACL> acls) {
setStyleAttribute("margin-top", "10px");
setStyleAttribute("margin-bottom", "10px");
setSize(350, 30);
radioGroup.mask("Loading ACLs");
for (WorkspaceACL acl : acls) {
if(acl.getUserType().equals(USER_TYPE.OTHER)){
Radio radio = createRadio(acl);
radioGroup.add(radio);
}
}
radioGroup.unmask();
add(radioGroup);
}
private Radio createRadio(WorkspaceACL acl) {
Radio radio = new Radio();
// check.setId(dsm.getId());
// check.setBoxLabel(dsm.getName() + " ("+property+")");
radio.setBoxLabel(acl.getLabel());
radio.setValueAttribute(acl.getLabel());
radio.setData(WORKSPACEACL, acl);
radio.setToolTip(new ToolTipConfig(acl.getDescription()));
radio.setValue(acl.getDefaultValue());
return radio;
}
public WorkspaceACL getSelectedACL() {
if (radioGroup.getValue()!=null)
return (WorkspaceACL) radioGroup.getValue().getData(WORKSPACEACL);
return null;
}
}

View File

@ -0,0 +1,140 @@
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.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 = "WORKSPACEACLGROUP";
// private ButtonGroup buttonGroup;
private HorizontalPanel hp = new HorizontalPanel();
private WorkspaceACL selectedAcl = null;
public PanelTogglePermission(List<WorkspaceACL> acls) {
// 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);
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

@ -0,0 +1,121 @@
package org.gcube.portlets.widgets.workspacesharingwidget.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;
}
}

View File

@ -0,0 +1,113 @@
package org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing;
import java.util.ArrayList;
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.shared.InfoContactModel;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*
*/
public class UserStore implements ContactFetcher{
public static List<InfoContactModel> listAllContact = null;
// public boolean syncronizeCleanSharedUser = false;
public UserStore() {
}
@Override
public void getListContact(AsyncCallback<List<InfoContactModel>> callback, boolean reloadList){
if(reloadList || listAllContact==null)
loadAllUsersFromServer(callback);
else
callback.onSuccess(listAllContact);
}
@Override
public void getListSharedUserByFolderId(String sharedFolderId, AsyncCallback<List<InfoContactModel>> callback){
loadSharedUserBySharedFolderId(sharedFolderId, callback);
}
private void loadAllUsersFromServer(final AsyncCallback<List<InfoContactModel>> callback){
listAllContact = new ArrayList<InfoContactModel>();
WorkspaceSharingController.rpcWorkspaceSharingService.getAllContacts(new AsyncCallback<List<InfoContactModel>>() {
@Override
public void onSuccess(List<InfoContactModel> result) {
GWT.log("loaded "+result.size() + " contacts from server");
listAllContact = result;
callback.onSuccess(listAllContact);
}
@Override
public void onFailure(Throwable caught) {
MessageBox.alert("Error", ConstantsSharing.SERVER_ERROR +" retrieving user " + ConstantsSharing.TRY_AGAIN, null);
callback.onFailure(caught);
}
});
}
private void loadSharedUserBySharedFolderId(final String sharedFolderId, final AsyncCallback<List<InfoContactModel>> callback){
// comboSharedUsers.mask("Loading users");
WorkspaceSharingController.rpcWorkspaceSharingService.getListUserSharedByFolderSharedId(sharedFolderId, new AsyncCallback<List<InfoContactModel>>() {
@Override
public void onFailure(Throwable caught) {
MessageBox.alert("Error", ConstantsSharing.SERVER_ERROR +" retrieving user. " + ConstantsSharing.TRY_AGAIN, null);
callback.onFailure(caught);
}
@Override
public void onSuccess(List<InfoContactModel> result) {
GWT.log("loaded "+result.size() + " contacts from server for "+sharedFolderId);
callback.onSuccess(result);
}
});
}
@Override
public List<InfoContactModel> getExclusiveContactsFromAllContact(List<InfoContactModel> listSharedUser){
List<InfoContactModel> listExclusiveContact = new ArrayList<InfoContactModel>(listAllContact);
for (InfoContactModel contact : listSharedUser) {
if(listAllContact.contains(contact)){
listExclusiveContact.remove(contact);
}
}
return listExclusiveContact;
}
@Override
public void getOwner(final String sharedFolderId,final AsyncCallback<InfoContactModel> callback) {
WorkspaceSharingController.rpcWorkspaceSharingService.getOwnerByItemId(sharedFolderId, new AsyncCallback<InfoContactModel>() {
@Override
public void onFailure(Throwable caught) {
GWT.log("an error occured in get Owner by Id "+sharedFolderId + " "+caught.getMessage());
}
@Override
public void onSuccess(InfoContactModel result) {
callback.onSuccess(result);
}
});
}
}

View File

@ -0,0 +1,25 @@
package org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.Widget;
/**
*
* @author Massimiliano Assante, ISTI-CNR
* @version 0.1 Sep 2012
*
*/
public class BulletList extends ComplexPanel {
public BulletList() {
setElement(DOM.createElement("ul"));
}
public void add(Widget w) {
super.add(w, getElement());
}
public void insert(Widget w, int beforeIndex) {
super.insert(w, getElement(), beforeIndex, true);
}
}

View File

@ -0,0 +1,61 @@
package org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyDownEvent;
import com.google.gwt.event.dom.client.KeyDownHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.Widget;
/**
*
* @author Massimiliano Assante, ISTI-CNR
* @version 0.1 Sep 2012
*
*/
public class ListItem extends ComplexPanel {
HandlerRegistration clickHandler;
public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) {
return addDomHandler(handler, KeyDownEvent.getType());
}
public HandlerRegistration addClickHandler(ClickHandler handler) {
return addDomHandler(handler, ClickEvent.getType());
}
public String getHTML() {
return DOM.getInnerHTML(getElement());
}
public void setHTML(String html) {
DOM.setInnerHTML(getElement(), (html == null) ? "" : html);
}
public ListItem() {
setElement(DOM.createElement("li"));
}
public void setId(String id) {
DOM.setElementAttribute(getElement(), "id", id);
}
public void add(Widget w) {
super.add(w, getElement());
}
public void insert(Widget w, int beforeIndex) {
super.insert(w, getElement(), beforeIndex, true);
}
public String getText() {
return DOM.getInnerText(getElement());
}
public void setText(String text) {
DOM.setInnerText(getElement(), (text == null) ? "" : text);
}
}

View File

@ -0,0 +1,305 @@
package org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.widgets.workspacesharingwidget.client.ConstantsSharing;
import org.gcube.portlets.widgets.workspacesharingwidget.client.resources.Resources;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.Style.Orientation;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.Style.SortDir;
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
import com.extjs.gxt.ui.client.dnd.GridDragSource;
import com.extjs.gxt.ui.client.dnd.GridDropTarget;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.store.Store;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
import com.extjs.gxt.ui.client.widget.Label;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.VerticalPanel;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.StoreFilterField;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.RowData;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
public class MultiDragContact extends Dialog {
private GridDropTarget dropSource;
private GridDropTarget dropTarget;
private ListStore<InfoContactModel> storeSource = new ListStore<InfoContactModel>();
private ListStore<InfoContactModel> storeTarget = new ListStore<InfoContactModel>();
private TextArea textAreaAlreadyShared;
private Grid<InfoContactModel> gridAllContacts;
private Grid<InfoContactModel> gridShareWith;
public MultiDragContact() {
setStyleAttribute("margin", "10px");
setSize(563, 542);
setHeading("Group dragging contacts");
setIcon(Resources.getIconUsers());
setModal(true);
setScrollMode(Scroll.AUTOY);
setBodyStyle("padding: 9px; background: none");
setResizable(true);
setButtonAlign(HorizontalAlignment.CENTER);
setButtons(Dialog.OKCANCEL);
ContentPanel cpAlreadyShared = new ContentPanel();
cpAlreadyShared.setSize(530, 60);
cpAlreadyShared.setHeaderVisible(false);
cpAlreadyShared.setLayout(new FitLayout());
VerticalPanel vpShared = new VerticalPanel();
vpShared.setVerticalAlign(VerticalAlignment.MIDDLE);
vpShared.setHorizontalAlign(HorizontalAlignment.CENTER);
vpShared.setStyleAttribute("padding", "5px");
vpShared.setLayout(new FitLayout());
HorizontalPanel hpSharedContacts = new HorizontalPanel();
hpSharedContacts.setHorizontalAlign(HorizontalAlignment.CENTER);
hpSharedContacts.setVerticalAlign(VerticalAlignment.MIDDLE);
textAreaAlreadyShared = new TextArea();
// textField.setFieldLabel("Already shared with");
// textField.setHeight(30);
textAreaAlreadyShared.setWidth(401);
textAreaAlreadyShared.setHeight(43);
cpAlreadyShared.setStyleAttribute("padding-bottom", "5px");
textAreaAlreadyShared.setReadOnly(true);
cpAlreadyShared.add(textAreaAlreadyShared);
Label label = new Label("Already shared with");
label.setStyleAttribute("padding-right", "10px");
hpSharedContacts.add(label);
hpSharedContacts.add(textAreaAlreadyShared);
vpShared.add(hpSharedContacts);
cpAlreadyShared.add(vpShared);
add(cpAlreadyShared);
ContentPanel cp = new ContentPanel();
cp.setSize(530, 370);
cp.setHeaderVisible(false);
cp.setLayout(new RowLayout(Orientation.HORIZONTAL));
ToolBar toolBar = new ToolBar();
Button buttonHelp = new Button();
buttonHelp.setIcon(Resources.getIconInfo());
buttonHelp.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
MessageBox.info("Group dragging action", "Drag one or more contacts from the left (All Contacts) to the right (Share with) to add users in your sharing list.", null);
}
});
toolBar.add(buttonHelp);
setTopComponent(toolBar);
VerticalPanel vp = new VerticalPanel();
vp.setHorizontalAlign(HorizontalAlignment.CENTER);
vp.add(new Label("All Contacts"));
gridAllContacts = new Grid<InfoContactModel>(storeSource, createColumnModel());
storeSource.setDefaultSort(InfoContactModel.FULLNAME, SortDir.ASC);
storeSource.sort(InfoContactModel.FULLNAME, SortDir.ASC);
storeTarget.setDefaultSort(InfoContactModel.FULLNAME, SortDir.ASC);
storeTarget.sort(InfoContactModel.FULLNAME, SortDir.ASC);
StoreFilterField<InfoContactModel> filter = new StoreFilterField<InfoContactModel>() {
@Override
protected boolean doSelect(Store<InfoContactModel> store,
InfoContactModel parent, InfoContactModel record,
String property, String filter) {
String name = record.getName();
name = name.toLowerCase();
if (name.contains(filter.toLowerCase())) {
return true;
}
return false;
}
};
// filter.setFieldLabel("Filter Contacts");
filter.setWidth(247);
filter.setEmptyText("Filter All Contacts");
HorizontalPanel hp = new HorizontalPanel();
hp.setStyleAttribute("padding-top", "5px");
hp.setStyleAttribute("padding-bottom", "5px");
hp.add(filter);
filter.bind(storeSource);
gridAllContacts.setSize(250,310);
gridAllContacts.setBorders(false);
gridAllContacts.setAutoExpandColumn(InfoContactModel.FULLNAME);
gridAllContacts.setBorders(true);
vp.add(hp);
vp.add(gridAllContacts);
RowData rowData = new RowData(.5, 1);
rowData.setMargins(new Margins(6));
cp.add(vp, rowData);
vp = new VerticalPanel();
vp.setHorizontalAlign(HorizontalAlignment.CENTER);
vp.add(new Label("Share with..."));
gridShareWith = new Grid<InfoContactModel>(storeTarget, createColumnModel());
StoreFilterField<InfoContactModel> filter2 = new StoreFilterField<InfoContactModel>() {
@Override
protected boolean doSelect(Store<InfoContactModel> store,
InfoContactModel parent, InfoContactModel record,
String property, String filter) {
String name = record.getName();
name = name.toLowerCase();
if (name.contains(filter.toLowerCase())) {
return true;
}
return false;
}
};
// filter.setFieldLabel("Filter Contacts");
filter2.setWidth(247);
filter2.setEmptyText("Filter Share with");
hp = new HorizontalPanel();
hp.setStyleAttribute("padding-top", "5px");
hp.setStyleAttribute("padding-bottom", "5px");
hp.add(filter2);
filter2.bind(storeTarget);
gridShareWith.setSize(250, 310);
gridShareWith.setBorders(false);
gridShareWith.setAutoExpandColumn(InfoContactModel.FULLNAME);
gridShareWith.setBorders(true);
vp.add(hp);
vp.add(gridShareWith);
rowData = new RowData(.5, 1);
rowData.setMargins(new Margins(6, 6, 6, 0));
cp.add(vp, rowData);
new GridDragSource(gridAllContacts);
new GridDragSource(gridShareWith);
dropSource = new GridDropTarget(gridAllContacts);
dropSource.setAllowSelfAsSource(false);
dropTarget = new GridDropTarget(gridShareWith);
dropTarget.setAllowSelfAsSource(false);
add(cp);
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();
}
});
}
private ColumnModel createColumnModel() {
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
ColumnConfig column = new ColumnConfig();
column.setId(InfoContactModel.FULLNAME);
column.setHeader("Name");
column.setWidth(200);
configs.add(column);
// column = new ColumnConfig();
// column.setId("symbol");
// column.setHeader("Symbol");
// column.setWidth(100);
// configs.add(column);
return new ColumnModel(configs);
}
public void addSourceContacts(List<InfoContactModel> listContact){
gridAllContacts.mask("", ConstantsSharing.LOADINGSTYLE);
if(listContact!=null && listContact.size()>0){
// for (InfoContactModel infoContactModel : listContact) {
//
// if(infoContactModel.getName()!=null && !infoContactModel.getName().isEmpty())
// storeSource.add(infoContactModel);
// }
storeSource.add(listContact);
}
gridAllContacts.unmask();
}
public void addAlreadySharedContacts(List<InfoContactModel> listContact){
gridShareWith.mask("", ConstantsSharing.LOADINGSTYLE);
if(listContact!=null && listContact.size()>0){
String alreadyShared = "";
for (int i=0; i<listContact.size()-1; i++)
alreadyShared+=listContact.get(i).getName()+", ";
alreadyShared+=listContact.get(listContact.size()-1).getName();
textAreaAlreadyShared.setValue(alreadyShared);
}
gridShareWith.unmask();
}
public void addTargetContacts(List<InfoContactModel> listContact){
if(listContact!=null && listContact.size()>0)
storeTarget.add(listContact);
}
public void addTargetContact(InfoContactModel contact){
if(contact!=null)
storeTarget.add(contact);
}
public List<InfoContactModel> getTargetListContact(){
return storeTarget.getModels();
}
}

View File

@ -0,0 +1,274 @@
package org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.ContactFetcher;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyDownEvent;
import com.google.gwt.event.dom.client.KeyDownHandler;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
import com.google.gwt.user.client.ui.SuggestBox;
import com.google.gwt.user.client.ui.SuggestOracle;
import com.google.gwt.user.client.ui.TextBox;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @Feb 25, 2014
*
*/
public class MultiValuePanel extends Composite {
// private final WsMailServiceAsync mailingService = GWT.create(WsMailService.class);
private List<String> itemsSelected = new ArrayList<String>();
FlowPanel panel = new FlowPanel();
// private HandlerManager eventBus;
private HashMap<String, InfoContactModel> users = new HashMap<String, InfoContactModel>();
private BulletList listBullet = new BulletList();
private SuggestBox box;
private ContactFetcher userFetch;
private MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
/**
*
* @param userFetch the ContactFetcher
*/
public MultiValuePanel(ContactFetcher userFetch) {
this.userFetch = userFetch;
initWidget(panel);
panel.setWidth("100%");
listBullet.setStyleName("multivalue-panel-suggest");
final ListItem item = new ListItem();
final TextBox itemBox = new TextBox();
itemBox.getElement().setAttribute("style", "outline-color: -moz-use-text-color; outline-style: none; outline-width: medium; border: none;");
box = new SuggestBox(getSuggestions(), itemBox);
item.add(box);
listBullet.add(item);
// needed to be set on the itemBox instead of the box, otherwise backspace gets executed twice
itemBox.addKeyDownHandler(new KeyDownHandler() {
public void onKeyDown(KeyDownEvent event) {
// handle backspace
if (event.getNativeKeyCode() == KeyCodes.KEY_BACKSPACE) {
if ("".equals(itemBox.getValue().trim())) {
if(listBullet.getWidgetCount()>2){
ListItem li = (ListItem) listBullet.getWidget(listBullet.getWidgetCount() - 2);
if(li.getWidget(0) instanceof Paragraph){
Paragraph p = (Paragraph) li.getWidget(0);
// GWT.log("p "+p.getText() +" is removable : " + p.isRemovable());
if (itemsSelected.contains(p.getText()) && (p.isRemovable()==true)) {
itemsSelected.remove(p.getText());
GWT.log("Removing selected item: " + p.getText() + "'");
listBullet.remove(li);
}
itemBox.setFocus(true);
}
}
}
}
}
});
box.addSelectionHandler(new SelectionHandler<SuggestOracle.Suggestion>() {
public void onSelection(SelectionEvent<SuggestOracle.Suggestion> selectionEvent) {
chosenContactItem(itemBox, listBullet);
}
});
panel.add(listBullet);
box.getElement().setId("suggestion_box"); //needed for the focus on click
panel.getElement().setAttribute("onclick", "document.getElementById('suggestion_box').focus()");
// box.setFocus(true);
}
public void boxSetFocus(){
box.getElement().focus();
box.setFocus(true);
// panel.getElement().setAttribute("onclick", "document.getElementById('suggestion_box').focus()");
}
public FlowPanel getFlowPanel(){
return panel;
}
/**
* actually insert the contact in the flow panel
* @param itemBox
* @param list
*/
private void chosenContactItem(final TextBox itemBox, final BulletList list) {
if (itemBox.getValue() != null && !"".equals(itemBox.getValue().trim())) {
final ListItem displayItem = new ListItem();
displayItem.setStyleName("multivalue-panel-token-ws");
Paragraph p = new Paragraph(itemBox.getValue());
Span span = new Span("x");
span.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
removeListItem(displayItem, list);
}
});
displayItem.add(p);
displayItem.add(span);
//original value of the item selected
GWT.log("Adding selected item '" + itemBox.getValue());
itemsSelected.add(itemBox.getValue());
GWT.log("Total: " + itemsSelected);
list.insert(displayItem, list.getWidgetCount() - 1);
itemBox.setValue("");
itemBox.setFocus(true);
}
}
/**
*
* @return the selected contacts (user logins e.g. pino.pini)
*/
public List<InfoContactModel> getSelectedUser() {
if (users == null)
return new ArrayList<InfoContactModel>();
else {
List<InfoContactModel> toReturn = new ArrayList<InfoContactModel>();
for (String login : itemsSelected) {
InfoContactModel wsuser = users.get(login);
if(wsuser!= null && !toReturn.contains(wsuser))
toReturn.add(wsuser);
}
return toReturn;
}
}
private void removeListItem(ListItem displayItem, BulletList list) {
GWT.log("Removing: " + displayItem.getWidget(0).getElement().getInnerHTML(), null);
itemsSelected.remove(displayItem.getWidget(0).getElement().getInnerHTML());
list.remove(displayItem);
}
/**
*
* @return names of possible contacts
*/
private MultiWordSuggestOracle getSuggestions() {
userFetch.getListContact(contacts, false);
return oracle;
}
public void updateSuggestions(List<InfoContactModel> result) {
oracle.clear();
for (InfoContactModel wsUser : result) {
oracle.add(wsUser.getName());
}
}
private AsyncCallback<List<InfoContactModel>> contacts = new AsyncCallback<List<InfoContactModel>>() {
@Override
public void onFailure(Throwable caught) {
}
@Override
public void onSuccess(List<InfoContactModel> result) {
users.clear();
for (InfoContactModel wsUser : result) {
oracle.add(wsUser.getName());
users.put(wsUser.getName(), wsUser);
}
}
};
public void resetItemSelected(){
listBullet.clear();
itemsSelected.clear();
ListItem item = new ListItem();
item.add(box);
listBullet.add(item);
}
/**
*
* @param contact
* @param displayRemoveItem
*/
public void addRecipient(String fullName, boolean displayRemoveItem) {
if (fullName != null) {
TextBox itemBox = new TextBox();
itemBox.setText(fullName);
itemBox.setValue(fullName);
final ListItem displayItem = new ListItem();
Paragraph p = new Paragraph(fullName);
displayItem.add(p);
if(displayRemoveItem){
displayItem.setStyleName("multivalue-panel-token-ws");
p.setRemovable(true);
Span span = new Span("x");
span.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
removeListItem(displayItem, listBullet);
}
});
displayItem.add(span);
}
else{
displayItem.setStyleName("multivalue-panel-token-ws-notselectable");
p.setRemovable(false);
}
GWT.log("Adding selected wp item '" + itemBox.getValue());
itemsSelected.add(itemBox.getValue());
GWT.log("Total: " + itemsSelected);
listBullet.insert(displayItem, listBullet.getWidgetCount()-1);
itemBox.setValue("");
itemBox.setFocus(true);
}
}
public void clearList() {
listBullet.clear();
}
public SuggestBox getBox() {
return box;
}
}

View File

@ -0,0 +1,42 @@
package org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.Widget;
/**
*
* @author Massimiliano Assante, ISTI-CNR
* @version 0.1 Sep 2012
* changed by Francesco Mangiacrapa
*
*/
public class Paragraph extends Widget implements HasText {
boolean isRemovable = true;
public Paragraph() {
setElement(DOM.createElement("p"));
}
public Paragraph(String text) {
this();
setText(text);
}
public String getText() {
return getElement().getInnerText();
}
public void setText(String text) {
getElement().setInnerText(text);
}
public boolean isRemovable(){
return isRemovable;
}
public void setRemovable(boolean isRemovable) {
this.isRemovable = isRemovable;
}
}

View File

@ -0,0 +1,23 @@
package org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasText;
/**
*
* @author Massimiliano Assante, ISTI-CNR
* @version 0.1 Sep 2012
*
*/
public class Span extends HTML implements HasText {
public Span() {
super(DOM.createElement("span"));
}
public Span(String text) {
this();
setText(text);
}
}

View File

@ -0,0 +1,187 @@
/**
*
*/
package org.gcube.portlets.widgets.workspacesharingwidget.server;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.apache.log4j.Logger;
import org.gcube.common.homelibrary.home.User;
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.common.homelibrary.home.workspace.accessmanager.ACLType;
import org.gcube.portlets.widgets.workspacesharingwidget.server.util.UserUtil;
import org.gcube.portlets.widgets.workspacesharingwidget.server.util.WsUtil;
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.vomanagement.usermanagement.model.UserModel;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @Feb 25, 2014
*
*/
public class GWTWorkspaceSharingBuilder {
protected static Logger logger = Logger.getLogger(GWTWorkspaceSharingBuilder.class);
private InfoContactModel userLogged;
protected static HashMap<String, InfoContactModel> hashTestUser = null;
/**
* Used in test mode
* @return
*/
public static HashMap<String, InfoContactModel> getHashTestUsers(){
if(hashTestUser==null){
hashTestUser = new HashMap<String, InfoContactModel>();
hashTestUser.put("federico.defaveri", new InfoContactModel("federico.defaveri", "federico.defaveri", "Federico de Faveri"));
hashTestUser.put("antonio.gioia", new InfoContactModel("antonio.gioia", "antonio.gioia", "Antonio Gioia"));
hashTestUser.put("fabio.sinibaldi", new InfoContactModel("fabio.sinibaldi", "fabio.sinibaldi", "Fabio Sinibaldi"));
hashTestUser.put("pasquale.pagano", new InfoContactModel("pasquale.pagano", "pasquale.pagano", "Pasquale Pagano"));
hashTestUser.put(WsUtil.TEST_USER.toString(), new InfoContactModel(WsUtil.TEST_USER, WsUtil.TEST_USER, WsUtil.TEST_USER_FULL_NAME));
hashTestUser.put("francesco.mangiacrapa", new InfoContactModel("francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa"));
hashTestUser.put("massimiliano.assante", new InfoContactModel("massimiliano.assante", "massimiliano.assante", "Massimiliano Assante"));
}
return hashTestUser;
}
/**
* @param infoContactModel
*/
public void setUserLogged(InfoContactModel infoContactModel) {
this.userLogged = infoContactModel;
}
/**
*
* @param listUsers
* @return
* @throws InternalErrorException
*/
public List<InfoContactModel> buildGXTListContactsModel(List<UserModel> listUsers) throws InternalErrorException {
List<InfoContactModel> listContactsModel = new ArrayList<InfoContactModel>();
if(listUsers==null)
return listContactsModel;
logger.trace("List<UserModel> size returned from Portal VO is: "+ listUsers.size());
logger.trace("Building list contact model list user model");
for (UserModel userModel : listUsers) {
String fullName = userModel.getFullname();
if(fullName!=null && !fullName.isEmpty())
listContactsModel.add(new InfoContactModel(userModel.getUserId()+"", userModel.getScreenName(), fullName));
else
logger.trace("buildGXTListContactsModel doesn't return user: "+userModel.getScreenName()+ "because name is null or empty");
}
logger.trace("List contact model completed, return " +listContactsModel.size()+" contacts");
return listContactsModel;
}
/**
*
* @param listPortalLogin
* @return
*/
public List<InfoContactModel> buildGxtInfoContactsFromPortalLogins(List<String> listPortalLogin){
List<InfoContactModel> listContact = new ArrayList<InfoContactModel>();
for (String portalLogin : listPortalLogin)
listContact.add(buildGxtInfoContactFromPortalLogin(portalLogin));
return listContact;
}
/**
*
* @param portalLogin
* @return
*/
protected InfoContactModel buildGxtInfoContactFromPortalLogin(String portalLogin){
if(portalLogin==null){
logger.warn("portal login is null, return empty");
portalLogin = "";
}
return new InfoContactModel(portalLogin, portalLogin, UserUtil.getUserFullName(portalLogin));
}
/**
* Used in test mode
* @param listPortalLogin
* @return
*/
protected List<InfoContactModel> buildGxtInfoContactFromPortalLoginTestMode(List<String> listPortalLogin){
List<InfoContactModel> listContact = new ArrayList<InfoContactModel>();
for (String portalLogin : listPortalLogin)
listContact.add(getHashTestUsers().get(portalLogin));
return listContact;
}
/**
*
* @param user
* @return
* @throws InternalErrorException
*/
public InfoContactModel buildGXTInfoContactModel(User user) throws InternalErrorException{
if(user!=null)
return new InfoContactModel(user.getId(), user.getPortalLogin(), UserUtil.getUserFullName(user.getPortalLogin()));
return new InfoContactModel();
}
public List<WorkspaceACL> getWorkspaceACLFromACLs(List<ACLType> types) throws Exception{
List<WorkspaceACL> acls = new ArrayList<WorkspaceACL>();
for (ACLType acl : types) {
switch (acl) {
case ADMINISTRATOR:
acls.add(new WorkspaceACL(acl.toString(), "Admin", false, USER_TYPE.ADMINISTRATOR, ""));
break;
case READ_ONLY:
acls.add(new WorkspaceACL(acl.toString(), "Read Only", false, USER_TYPE.OTHER, "Users can read any file but cannot update/delete"));
break;
case WRITE_OWNER:
acls.add(new WorkspaceACL(acl.toString(), "Write Own", true, USER_TYPE.OTHER, "Users can update/delete only their files"));
break;
case WRITE_ALL:
acls.add(new WorkspaceACL(acl.toString(), "Write Any", false, USER_TYPE.OTHER,"Any user can update/delete any file"));
break;
default:
acls.add(new WorkspaceACL(acl.toString(), acl.toString(), false, USER_TYPE.OTHER, ""));
break;
}
}
if(acls.size()==0)
throw new Exception("No ACLs rules found!");
return acls;
}
}

View File

@ -1,6 +1,31 @@
package org.gcube.portlets.widgets.workspacesharingwidget.server;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.log4j.Logger;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItemType;
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
import org.gcube.common.homelibrary.home.workspace.accessmanager.ACLType;
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
import org.gcube.portlets.widgets.workspacesharingwidget.client.ConstantsSharing;
import org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingService;
import org.gcube.portlets.widgets.workspacesharingwidget.server.notifications.NotificationsProducer;
import org.gcube.portlets.widgets.workspacesharingwidget.server.notifications.NotificationsUtil;
import org.gcube.portlets.widgets.workspacesharingwidget.server.util.ScopeUtilFilter;
import org.gcube.portlets.widgets.workspacesharingwidget.server.util.WsUtil;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL;
import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.UserManager;
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayGroupManager;
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayUserManager;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
@ -11,10 +36,165 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
WorkspaceSharingService {
protected Logger logger = Logger.getLogger(WorkspaceSharingServiceImpl.class);
protected GWTWorkspaceSharingBuilder getGWTWorkspaceBuilder()
{
return WsUtil.getGWTWorkspaceSharingBuilder(this.getThreadLocalRequest().getSession());
}
protected Workspace getWorkspace() throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException
{
return WsUtil.getWorkspace(this.getThreadLocalRequest().getSession());
}
protected NotificationsProducer getNotificationProducer(){
return WsUtil.getNotificationProducer(WsUtil.getAslSession(this.getThreadLocalRequest().getSession()));
}
protected ScopeUtilFilter getScopeUtilFilter(){
return WsUtil.getScopeUtilFilter(this.getThreadLocalRequest().getSession());
}
protected boolean isTestMode(){
return WsUtil.withoutPortal;
}
public String greetServer(String input) throws IllegalArgumentException {
return "Hello";
}
@Override
public List<InfoContactModel> getAllContacts() throws Exception {
try {
Workspace workspace = getWorkspace();
logger.trace("Get all contacts");
// WorkspaceItem parent = workspace.getItem(parentFileModel.getIdentifier()); //get item from workspace
// workspace.getAllScope();
GWTWorkspaceSharingBuilder builder = getGWTWorkspaceBuilder();
if(isTestMode()){
logger.warn("WORKSPACE PORTLET IS IN TEST MODE - RETURN TEST USERS");
List<InfoContactModel> listContactsModel = new ArrayList<InfoContactModel>();
// //TEST USERS
listContactsModel.add(new InfoContactModel("federico.defaveri", "federico.defaveri", "Federico de Faveri"));
listContactsModel.add(new InfoContactModel("antonio.gioia", "antonio.gioia", "Antonio Gioia"));
listContactsModel.add(new InfoContactModel("fabio.sinibaldi", "fabio.sinibaldi", "Fabio Sinibaldi"));
listContactsModel.add(new InfoContactModel("pasquale.pagano", "pasquale.pagano", "Pasquale Pagano"));
listContactsModel.add(new InfoContactModel(WsUtil.TEST_USER, WsUtil.TEST_USER, WsUtil.TEST_USER_FULL_NAME));
listContactsModel.add(new InfoContactModel("francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa"));
listContactsModel.add(new InfoContactModel("massimiliano.assante", "massimiliano.assante", "Massimiliano Assante"));
return listContactsModel;
}
UserManager userManag = new LiferayUserManager();
GroupManager gm = new LiferayGroupManager();
String groupId = gm.getRootVO().getGroupId();
logger.trace("user manager getting list users by group: "+groupId);
return builder.buildGXTListContactsModel(userManag.listUsersByGroup(groupId));
} catch (Exception e) {
logger.error("Error in server get all contacts ", e);
// return new ArrayList<InfoContactModel>();
throw new Exception(e.getMessage());
}
}
@Override
public List<InfoContactModel> getListUserSharedByFolderSharedId(String folderSharedId) throws Exception{
logger.trace("getListUserSharedByFolderSharedId "+ folderSharedId);
try {
Workspace workspace = getWorkspace();
WorkspaceItem wsItem = workspace.getItem(folderSharedId);
if(NotificationsUtil.isASharedFolder(wsItem)){
WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) wsItem;
GWTWorkspaceSharingBuilder builder = getGWTWorkspaceBuilder();
List<String> listPortalLogin = wsFolder.getUsers();
logger.trace("getListUserSharedByFolderSharedId return "+ listPortalLogin.size() + " user");
if(isTestMode())
return builder.buildGxtInfoContactFromPortalLoginTestMode(listPortalLogin);
return builder.buildGxtInfoContactsFromPortalLogins(listPortalLogin);
}
else{
logger.trace("the item with id: "+folderSharedId+ " is not "+WorkspaceItemType.SHARED_FOLDER);
//DEBUG
//System.out.println("the item with id: "+folderSharedId+ " is not "+WorkspaceItemType.SHARED_FOLDER);
}
return new ArrayList<InfoContactModel>();
} catch (Exception e) {
logger.error("Error in getListUserSharedByItemId ", e);
throw new Exception(e.getMessage());
}
}
@Override
public InfoContactModel getOwnerByItemId(String itemId) throws Exception {
logger.trace("get Owner By ItemId "+ itemId);
try {
Workspace workspace = getWorkspace();
WorkspaceItem wsItem = workspace.getItem(itemId);
GWTWorkspaceSharingBuilder builder = getGWTWorkspaceBuilder();
return builder.buildGXTInfoContactModel(wsItem.getOwner());
} catch (Exception e) {
logger.error("Error in getOwnerByItemId ", e);
throw new Exception(e.getMessage());
}
}
/**
*
* @return
* @throws Exception
*/
@Override
public List<WorkspaceACL> getACLs() throws Exception{
try {
GWTWorkspaceSharingBuilder builder = getGWTWorkspaceBuilder();
return builder.getWorkspaceACLFromACLs(Arrays.asList(ACLType.values()));
} catch (Exception e) {
logger.error("Error in server get ACLs", e);
String error = ConstantsSharing.SERVER_ERROR +" get ACL rules. "+e.getMessage();
throw new Exception(error);
}
}
@Override
public String getMyLogin(){
ASLSession asl = WsUtil.getAslSession(this.getThreadLocalRequest().getSession());
return asl.getUsername();
}
}

View File

@ -0,0 +1,629 @@
/**
*
*/
package org.gcube.portlets.widgets.workspacesharingwidget.server.notifications;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.applicationsupportlayer.social.NotificationsManager;
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.portlets.widgets.workspacesharingwidget.server.util.DiffereceBeetweenInfoContactModel;
import org.gcube.portlets.widgets.workspacesharingwidget.server.util.UserUtil;
import org.gcube.portlets.widgets.workspacesharingwidget.server.util.WsUtil;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*
*/
public class NotificationsProducer {
protected ScopeBean scope;
protected static Logger logger = Logger.getLogger(NotificationsProducer.class);
protected NotificationsManager notificationsMng;
protected ASLSession aslSession;
protected String userId;
/**
*
* @param aslSession
*/
public NotificationsProducer(ASLSession aslSession) {
this.notificationsMng = WsUtil.getNotificationManager(aslSession);
this.aslSession = aslSession;
this.userId = aslSession.getUsername();
}
public NotificationsManager getNotificationsMng() {
return notificationsMng;
}
public void setNotificationMng(NotificationsManager notificationMng) {
this.notificationsMng = notificationMng;
}
public ASLSession getAslSession() {
return aslSession;
}
/**
* Runs a new thread to notify the contacts passed in input
* @param listContacts
* @param sharedFolder
*/
public void notifyFolderSharing(final List<InfoContactModel> listContacts, final WorkspaceFolder sharedFolder) {
new Thread(){
@Override
public void run() {
logger.trace("Send notifies folder sharing is running...");
for (InfoContactModel infoContactModel : listContacts) {
try{
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
if(infoContactModel.getLogin().compareTo(userId)!=0){
logger.trace("Sending notification new share folder "+sharedFolder.getName()+" for user "+infoContactModel.getLogin());
//DEBUG
System.out.println("Sending notification new share folder "+sharedFolder.getName()+" for user "+infoContactModel.getLogin());
boolean notify = notificationsMng.notifyFolderSharing(infoContactModel.getLogin(), sharedFolder);
if(!notify)
logger.error("An error occured when notify user: "+infoContactModel.getLogin());
}
}catch (Exception e) {
logger.error("An error occured in notifyFolderSharing ", e);
e.printStackTrace();
}
}
logger.trace("notifies share folder is completed");
}
}.start();
}
/**
* Runs a new thread to notify the contacts passed in input
* @param folderItem
* @param listContacts
* @param sharedFolder
*/
public void notifyFolderRenamed(final List<InfoContactModel> listSharedContact, final WorkspaceItem folderItem, final String itemOldName, final String itemNewName, final String idsharedFolder) {
new Thread(){
@Override
public void run() {
logger.trace("Send notifies shared folder was renamed is running...");
try {
if(NotificationsUtil.checkIsRootFolderShared(folderItem.getId(), idsharedFolder)){
logger.trace("Notification isn't sent because the event is on root shared folder");
return;
}
} catch (InternalErrorException e1) {
logger.error("An error occurred in checkIsRootFolderShared ", e1);
return;
}
for (InfoContactModel infoContactModel : listSharedContact) {
try{
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
if(infoContactModel.getLogin().compareTo(userId)!=0){
logger.trace("Sending notification share folder "+itemOldName+" was renamed as " + itemNewName+ "for user "+infoContactModel.getLogin());
//DEBUG
System.out.println("Sending notification share folder "+itemOldName+" was renamed as " + itemNewName+ "for user "+infoContactModel.getLogin());
boolean notify = notificationsMng.notifyFolderRenaming(infoContactModel.getLogin(), itemOldName, itemNewName, idsharedFolder);
if(!notify)
logger.error("An error occured when notify user: "+infoContactModel.getLogin());
}
}catch (Exception e) {
logger.error("An error occured in notifyFolderRenamed ", e);
e.printStackTrace();
}
}
logger.trace("notifies share folder was renamed is completed");
}
}.start();
}
/**
* Runs a new thread to notify the contacts passed in input
* @param listContacts
* @param sharedFolder
*/
public void notifyItemRenamed(final List<InfoContactModel> listSharedContact, final String previousName, final WorkspaceItem item, final WorkspaceFolder sharedFolder) {
new Thread(){
@Override
public void run() {
logger.trace("Send notifies shared item was updated is running...");
for (InfoContactModel infoContactModel : listSharedContact) {
try{
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
if(infoContactModel.getLogin().compareTo(userId)!=0){
logger.trace("Sending notification to user "+infoContactModel.getLogin() + " updated item "+item.getName());
//DEBUG
System.out.println("Sending notification to user "+infoContactModel.getLogin() + " updated item "+item.getName());
// notificationsMng.notifyItemRenaming(infoContactModel.getLogin(), previousName, item, sharedFolder);
boolean notify = notificationsMng.notifyItemRenaming(infoContactModel.getLogin(), previousName, item);
if(!notify)
logger.error("An error occured when notify user: "+infoContactModel.getLogin());
}
}catch (Exception e) {
logger.error("An error occured in notifyItemUpdated ", e);
e.printStackTrace();
}
}
logger.trace("notifies shared item was updated is completed");
}
}.start();
}
/**
* Runs a new thread to notify the new contacts passed in input
* @param listSharedContact - list of contacts already shared
* @param listSharingContact - list of "new" contacts witch share
* @param sharedFolder - the shared folder
*/
public void notifyAddedUsersToSharing(final List<InfoContactModel> listSharedContact, final List<InfoContactModel> listSharingContact, final WorkspaceSharedFolder sharedFolder) {
new Thread() {
@Override
public void run() {
try{
DiffereceBeetweenInfoContactModel diff = new DiffereceBeetweenInfoContactModel(listSharingContact, listSharedContact);
List<InfoContactModel> listExclusiveContacts = diff.getDifferentsContacts();
System.out.println("list exclusive contacts: "+listExclusiveContacts);
if(listExclusiveContacts.size()>0){
if(listExclusiveContacts.size()==1){ //CASE ONLY ONE CONTACS WAS ADDED
InfoContactModel infoContactModel = listExclusiveContacts.get(0);
for (InfoContactModel contact : listSharedContact) { //NOTIFIES ALREADY SHARED CONTACTS THATH A NEW USER WAS ADDED
try{
logger.trace("Sending notification to user "+contact.getLogin()+", added user "+ infoContactModel.getLogin() +" to share folder "+sharedFolder.getName());
//DEBUG
// System.out.println("Sending notification added user "+ infoContactModel.getLogin() +" to share folder "+sharedFolder.getName() + " for user "+contact.getLogin());
boolean notify = notificationsMng.notifyFolderAddedUser(contact.getLogin(), sharedFolder, infoContactModel.getLogin());
if(!notify)
logger.error("An error occured when notifies user: "+contact.getLogin());
}catch (Exception e) {
logger.error("An error occured in notifyFolderAddedUser ", e);
e.printStackTrace();
}
}
List<InfoContactModel> listCts = new ArrayList<InfoContactModel>();
listCts.add(infoContactModel);
notifyFolderSharing(listCts, sharedFolder); //NOTIFIER NEW USER OF SHARING FOLDER
}else{ //CASE MORE THEN ONE CONTACS WAS ADDED
List<String> listLogins = UserUtil.getListLoginByInfoContactModel(listExclusiveContacts);
for (InfoContactModel contact : listSharedContact) { //NOTIFIES ALREADY SHARED CONTACTS THATH A NEW USER WAS ADDED
try{
logger.trace("Sending notification to user "+contact.getLogin()+", added "+listLogins.size()+" users to share folder "+sharedFolder.getName());
//DEBUG
// System.out.println("Sending notification added user "+ infoContactModel.getLogin() +" to share folder "+sharedFolder.getName() + " for user "+contact.getLogin());
boolean notify = notificationsMng.notifyFolderAddedUsers(contact.getLogin(), sharedFolder, listLogins);
if(!notify)
logger.error("An error occured when notifies user: "+contact.getLogin());
}catch (Exception e) {
logger.error("An error occured in notifyFolderAddedUser ", e);
e.printStackTrace();
}
}
notifyFolderSharing(listExclusiveContacts, sharedFolder); //NOTIFIER NEW USER OF SHARING FOLDER
}
}
}catch (Exception e) {
logger.error("An error occured in notifyAddedUserToSharing ", e);
e.printStackTrace();
}
}
}.start();
}
/**
* Runs a new thread to notify the contacts passed in input
* @param listContacts
* @param unSharedFolder
*/
public void notifyFolderUnSharing(final List<InfoContactModel> listContacts, final WorkspaceFolder unSharedFolder) {
new Thread() {
@Override
public void run() {
// printContacts(listContacts);
logger.trace("Send notifies folder un share is running...");
for (InfoContactModel infoContactModel : listContacts) {
try{
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
if(infoContactModel.getLogin().compareTo(userId)!=0){
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" un shared folder "+unSharedFolder.getName());
//DEBUG
System.out.println("Sending notification to user "+infoContactModel.getLogin() +" un shared folder "+unSharedFolder.getName());
boolean notify = notificationsMng.notifyFolderRemovedUser(infoContactModel.getLogin(), unSharedFolder);
if(!notify)
logger.error("An error occured when notifies user: "+infoContactModel.getLogin());
}
}catch (Exception e) {
logger.error("An error occured in notifyFolderUnSharing ", e);
e.printStackTrace();
}
}
logger.trace("notifies of un share notifications is completed");
}
}.start();
}
/**
* Runs a new thread to notify the contacts passed in input
* @param listContacts
* @param workspaceItem
*/
public void notifyAddedItemToSharing(final List<InfoContactModel> listContacts, final WorkspaceItem workspaceItem, final WorkspaceFolder sharedFolder) {
new Thread() {
@Override
public void run() {
// printContacts(listContacts);
logger.trace("Send notifies added item in sharedfolder is running...");
//DEBUG
System.out.println("Send notifies added item in sharedfolder is running...");
for (InfoContactModel infoContactModel : listContacts) {
try{
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
if(infoContactModel.getLogin().compareTo(userId)!=0){
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" added item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
//DEBUG
System.out.println("Sending notification to user "+infoContactModel.getLogin() +" added item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
//DEBUG
// System.out.println("Send notify folder un share user "+infoContactModel.getLogin());
boolean notify = notificationsMng.notifyAddedItem(infoContactModel.getLogin(), workspaceItem, sharedFolder);
if(!notify){
logger.error("An error occured when notify user: "+infoContactModel.getLogin());
//DEBUG
System.out.println("An error occured when notify user: "+infoContactModel.getLogin());
}
}
}catch (Exception e) {
logger.error("An error occured in notifyAddedItemToSharing ", e);
e.printStackTrace();
}
}
logger.trace("notifies of added item in shared folder is completed");
//DEBUG
System.out.println("notifies of added item in shared folder is completed");
}
}.start();
}
/**
* Runs a new thread to notify the contacts passed in input
* @param listContacts
* @param workspaceItem
*/
public void notifyUpdatedItemToSharing(final List<InfoContactModel> listContacts, final WorkspaceItem workspaceItem, final WorkspaceFolder sharedFolder) {
new Thread() {
@Override
public void run() {
// printContacts(listContacts);
logger.trace("Send notifies updated item in shared folder is running...");
//DEBUG
System.out.println("Send notifies updated item in shared folder is running...");
for (InfoContactModel infoContactModel : listContacts) {
try{
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
if(infoContactModel.getLogin().compareTo(userId)!=0){
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" updated item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
//DEBUG
System.out.println("Sending notification to user "+infoContactModel.getLogin() +" updated item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
//DEBUG
// System.out.println("Send notify folder un share user "+infoContactModel.getLogin());
boolean notify = notificationsMng.notifyUpdatedItem(infoContactModel.getLogin(), workspaceItem, sharedFolder);
if(!notify){
logger.error("An error updated when notify user: "+infoContactModel.getLogin());
//DEBUG
System.out.println("An error updated when notify user: "+infoContactModel.getLogin());
}
}
}catch (Exception e) {
logger.error("An error updated in notifyAddedItemToSharing ", e);
e.printStackTrace();
}
}
logger.trace("notifies of updated item in shared folder is completed");
//DEBUG
System.out.println("notifies of updated item in shared folder is completed");
}
}.start();
}
/**
* Runs a new thread to notify the contacts passed in input
* @param listContacts
* @param sharedFolder
*/
public void notifyMovedItemToSharing(final List<InfoContactModel> listContacts, final WorkspaceItem workspaceItem, final WorkspaceFolder sharedFolder) {
new Thread() {
@Override
public void run() {
logger.trace("Sending notification remove item in shared folder is running...");
// printContacts(listContacts);
try {
if(NotificationsUtil.checkIsRootFolderShared(workspaceItem.getId(), sharedFolder.getId())){
logger.trace("Notification isn't sent because the event is on root shared folder");
return;
}
} catch (InternalErrorException e1) {
logger.error("An error occurred in checkIsRootFolderShared ", e1);
return;
}
logger.trace("Sending notification moved item in shared folder is running...");
System.out.println("Sending notification moved item in shared folder is running...");
for (InfoContactModel infoContactModel : listContacts) {
try{
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
if(infoContactModel.getLogin().compareTo(userId)!=0){
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" moved item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
//DEBUG
System.out.println("Sending notification to user "+infoContactModel.getLogin() +" moved item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
boolean notify = notificationsMng.notifyMovedItem(infoContactModel.getLogin(), workspaceItem, sharedFolder);
if(!notify){
logger.error("An error occured when notify user: "+infoContactModel.getLogin());
//DEBUG
System.out.println("An error occured when notify user: "+infoContactModel.getLogin());
}
}
}catch (Exception e) {
logger.error("An error occurred in notifyMovedItemToSharing ", e);
e.printStackTrace();
}
}
logger.trace("notifies of moved item in shared folder is completed");
//DEBUG
System.out.println("notifies of moved item in shared folder is completed");
}
}.start();
}
/**
* Runs a new thread to notify the contacts passed in input
* @param listContacts
* @param sharedFolder
*/
public void notifyRemovedItemToSharing(final List<InfoContactModel> listContacts, final String itemName, final WorkspaceFolder sharedFolder) {
new Thread() {
@Override
public void run() {
logger.trace("Sending notification remove item in shared folder is running...");
// printContacts(listContacts);
if(itemName==null || itemName.isEmpty()){
logger.trace("Notification isn't sent - itemName is null or empty");
return;
}
if(sharedFolder==null){
logger.trace("Notification isn't sent - sharedFolder is null");
}
logger.trace("Sending notification removed item in shared folder is running...");
System.out.println("Sending notification removed item in shared folder is running...");
for (InfoContactModel infoContactModel : listContacts) {
try{
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
if(infoContactModel.getLogin().compareTo(userId)!=0){
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" removed item "+itemName+" in shared folder "+sharedFolder.getName());
//DEBUG
System.out.println("Sending notification to user "+infoContactModel.getLogin() +" removed item "+itemName+" in shared folder "+sharedFolder.getName());
boolean notify = notificationsMng.notifyRemovedItem(infoContactModel.getLogin(), itemName, sharedFolder);
if(!notify){
logger.error("An error occured when notify user: "+infoContactModel.getLogin());
//DEBUG
System.out.println("An error occured when notify user: "+infoContactModel.getLogin());
}
}
}catch (Exception e) {
logger.error("An error occurred in notifyRemovedItemToSharing ", e);
e.printStackTrace();
}
}
logger.trace("notifies of moved item in shared folder is completed");
//DEBUG
System.out.println("notifies of moved item in shared folder is completed");
}
}.start();
}
//DEBUG
private void printContacts(List<InfoContactModel> listContacts){
System.out.println("Print contacts");
for (InfoContactModel infoContactModel : listContacts) {
System.out.println(infoContactModel);
}
System.out.println("End print contacts");
}
public static void main(String[] args) throws Exception
{
String sessionID = "1";
String user = "francesco.mangiacrapa";
String scopeString = "/gcube/devsec/devVRE";
String fullName = "Francesco Mangiacrapa";
ScopeBean scope;
ASLSession session;
session = SessionManager.getInstance().getASLSession(sessionID, user);
scope = new ScopeBean(scopeString);
session.setScope(scope.toString());
session.setUserAvatarId(user + "Avatar");
session.setUserFullName(fullName);
NotificationsProducer feeder = new NotificationsProducer(session);
}
}

View File

@ -0,0 +1,259 @@
/**
*
*/
package org.gcube.portlets.widgets.workspacesharingwidget.server.notifications;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItemType;
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
import org.gcube.portlets.widgets.workspacesharingwidget.server.GWTWorkspaceSharingBuilder;
import org.gcube.portlets.widgets.workspacesharingwidget.server.util.WsUtil;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @May 27, 2013
*
*/
public class NotificationsUtil {
protected static Logger logger = Logger.getLogger(NotificationsUtil.class);
/**
* Send a notification if an item is added or updated to sharing folder
* @param httpSession
* @param sourceItem
* @param sourceSharedId
* @param folderDestinationItem
*/
public static void checkSendNotifyChangedItemToShare(HttpSession httpSession, final WorkspaceItem sourceItem, final String sourceSharedId, final WorkspaceItem folderDestinationItem, boolean isOverwrite) {
logger.trace("checkSendNotifyAddItemToShare");
if(folderDestinationItem!=null){
try{
//if folder destination is shared folder
if(folderDestinationItem.isShared()){ //Notify Added Item To Sharing?
logger.trace("checkNotifyAddItemToShare source item: "+sourceItem.getName()+" sourceSharedId: "+sourceSharedId + " folder destination: "+folderDestinationItem.getName() + " folder destination shared folder id: "+folderDestinationItem.getIdSharedFolder());
//share condition is true if source shared folder is not null
boolean shareChangeCondition = sourceSharedId==null?false:true;
//System.out.println("shareChangeCondition add item: "+ shareChangeCondition);
logger.trace("shareChangeCondition add item: "+shareChangeCondition);
//if shareChangeCondition is true.. notifies added item to sharing
if(shareChangeCondition){
Workspace workspace = WsUtil.getWorkspace(httpSession);
List<InfoContactModel> listContacts = getListUserSharedByFolderSharedId(workspace, folderDestinationItem.getIdSharedFolder());
WorkspaceItem destinationSharedFolder = workspace.getItem(folderDestinationItem.getIdSharedFolder());
NotificationsProducer np = new NotificationsProducer(WsUtil.getAslSession(httpSession));
//SWITCH BEETWEEN ADDED OR UPDATED
if(!isOverwrite)
np.notifyAddedItemToSharing(listContacts, sourceItem, (WorkspaceFolder) destinationSharedFolder);
else
np.notifyUpdatedItemToSharing(listContacts, sourceItem, (WorkspaceFolder) destinationSharedFolder);
logger.trace("The notifies was sent correctly");
// np.notifyAddedItemToSharing(listContacts, (WorkspaceFolder) folderDestinationItem);
}
}
else
logger.trace("folder destination is not shared");
}catch (Exception e) {
logger.error("An error occurred in checkSendNotifyAddItemToShare ",e);
}
}else
logger.warn("The notifies is failure in checkSendNotifyAddItemToShare because folder destination item is null");
}
/**
*
* @param workspace
* @param idSharedFolder
* @return
* @throws Exception
*/
public static List<InfoContactModel> getListUserSharedByFolderSharedId(Workspace workspace, String idSharedFolder) throws Exception {
logger.trace("getListUserSharedByFolderSharedId "+ idSharedFolder);
try {
WorkspaceItem wsItem = workspace.getItem(idSharedFolder);
if(isASharedFolder(wsItem)){
WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) wsItem;
GWTWorkspaceSharingBuilder builder = new GWTWorkspaceSharingBuilder();
List<String> listPortalLogin = wsFolder.getUsers();
logger.trace("getListUserSharedByFolderSharedId return "+ listPortalLogin.size() + " user");
return builder.buildGxtInfoContactsFromPortalLogins(listPortalLogin);
}
else{
logger.trace("the item with id: "+idSharedFolder+ " is not "+WorkspaceItemType.SHARED_FOLDER);
//DEBUG
//System.out.println("the item with id: "+folderSharedId+ " is not "+WorkspaceItemType.SHARED_FOLDER);
}
return new ArrayList<InfoContactModel>();
} catch (Exception e) {
logger.error("Error in getListUserSharedByItemId ", e);
throw new Exception(e.getMessage());
}
}
/**
*
* @param httpSession
* @param sourceItemIsShared
* @param oldItemName
* @param oldItemId
* @param sourceFolderSharedId
*/
public static void checkSendNotifyRemoveItemToShare(HttpSession httpSession, final boolean sourceItemIsShared, final String oldItemName, String oldItemId, final String sourceFolderSharedId) {
logger.trace("checkNotifyRemoveItemToShare:");
try{
if(!sourceItemIsShared){
logger.trace("checkSendNotifyRemoveItemToShare returned, source item is not shared");
return;
}
String idSharedFolder = sourceFolderSharedId!=null?sourceFolderSharedId:"";
// System.out.println("shareChangeCondition remove item: "+ shareChangeCondition);
boolean isRootFolderShared = checkIsRootFolderShared(oldItemId, idSharedFolder);
logger.trace("isRootFolderShared is: "+ isRootFolderShared);
if(isRootFolderShared){
logger.trace("Notification doesn't send because the event is on root shared folder");
return;
}
boolean isSharedFolder = isASharedFolderForId(httpSession,idSharedFolder);
logger.trace("idSharedFolder is: "+ idSharedFolder +" is shared folder: "+isSharedFolder);
//Notify Removed Item To Sharing?
if(isSharedFolder && !isRootFolderShared){
Workspace workspace = WsUtil.getWorkspace(httpSession);
//get contacts
List<InfoContactModel> listContacts = getListUserSharedByFolderSharedId(workspace, idSharedFolder);
WorkspaceItem sourceSharedFolder = workspace.getItem(idSharedFolder);
//System.out.println(" name sourceSharedFolder: "+ sourceSharedFolder.getName());
NotificationsProducer np = new NotificationsProducer(WsUtil.getAslSession(httpSession));
np.notifyRemovedItemToSharing(listContacts, oldItemName, (WorkspaceFolder) sourceSharedFolder);
logger.trace("The notifies was sent correctly");
}
}catch (Exception e) {
logger.error("An error occurred in checkSendNotifyRemoveItemToShare ",e);
}
}
/**
*
* @param wsItem
* @return
*/
public static boolean isASharedFolder(WorkspaceItem wsItem){
if(wsItem!=null)
return wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER);
return false;
}
/**
*
* @param wsItem
* @return
*/
public static boolean isASharedFolderForId(HttpSession httpSession, String itemId){
if(itemId==null || itemId.isEmpty())
return false;
try {
Workspace workspace = WsUtil.getWorkspace(httpSession);
WorkspaceItem wsItem = workspace.getItem(itemId);
if(wsItem!=null)
return wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER);
return false;
} catch (Exception e) {
logger.error("An errror occurred in isASharedFolderForId", e);
return false;
}
}
/**
*
* @param itemId
* @param rootFolderSharedId
* @return
*/
public static boolean checkIsRootFolderShared(String itemId, String rootFolderSharedId) {
logger.trace("checkIsRootFolderShared between [itemid: "+itemId +", rootFolderSharedId: "+rootFolderSharedId+"]");
if(itemId==null)
return false;
if(rootFolderSharedId==null)
return false;
if(itemId.compareTo(rootFolderSharedId)==0)
return true;
return false;
}
}

View File

@ -0,0 +1,114 @@
package org.gcube.portlets.widgets.workspacesharingwidget.server.util;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @Feb 25, 2014
*
*/
public class DiffereceBeetweenInfoContactModel {
private List<InfoContactModel> listOne;
private List<InfoContactModel> listTwo;
/**
* Get difference between listA and listB
* @param listA
* @param listB
*/
public DiffereceBeetweenInfoContactModel(List<InfoContactModel> listA, List<InfoContactModel> listB){
this.listOne = listA;
this.listTwo = listB;
}
/**
*
* @return what is in listA that is not in listB.
*/
public List<InfoContactModel> getDifferentsContacts(){
if(this.listOne==null)
return new ArrayList<InfoContactModel>();
if(this.listTwo==null || this.listTwo.size()==0)
return this.listOne;
List<InfoContactModel> difference = new ArrayList<InfoContactModel>();
boolean found;
for (InfoContactModel o1 : listOne) {
found = false;
for (InfoContactModel o2 : listTwo) {
if(compare(o1,o2)==0){
found = true;
break;
}
}
if(!found)
difference.add(o1);
}
return difference;
}
/**
*
* @param o1
* @param o2
* @return 0 if and only if o1.getName().compareTo(o2.getName())==0 && (o1.getLogin().compareTo(o2.getLogin())==0) is true
*/
public int compare(InfoContactModel o1, InfoContactModel o2) {
if (o1 == null) {
return -1;
} else if (o2 == null) {
return 1;
}
if (o1.getName().compareTo(o2.getName())==0 && (o1.getLogin().compareTo(o2.getLogin())==0))
return 0;
else
return -2;
}
/**
* test
* @param args
*/
public static void main(String[] args) {
List<InfoContactModel> listA = new ArrayList<InfoContactModel>();
listA.add(new InfoContactModel("federico.defaveri", "federico.defaveri", "Federico de Faveri"));
listA.add(new InfoContactModel("antonio.gioia", "antonio.gioia", "Antonio Gioia"));
listA.add(new InfoContactModel("fabio.sinibaldi", "fabio.sinibaldi", "Fabio Sinibaldi"));
listA.add(new InfoContactModel("pasquale.pagano", "pasquale.pagano", "Pasquale Pagano"));
listA.add(new InfoContactModel("francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa"));
listA.add(new InfoContactModel("massimiliano.assante", "massimiliano.assante", "Massimiliano Assante"));
List<InfoContactModel> listB = new ArrayList<InfoContactModel>();
listB.add(new InfoContactModel("federico.defaveri", "federico.defaveri", "Federico de Faveri"));
listB.add(new InfoContactModel("fabio.sinibaldi", "fabio.sinibaldi", "Fabio Sinibaldi"));
listB.add(new InfoContactModel("antonio.gioia", "antonio.gioia", "Antonio Gioia"));
listB.add(new InfoContactModel("pasquale.pagano", "pasquale.pagano", "Pasquale Pagano"));
DiffereceBeetweenInfoContactModel diff = new DiffereceBeetweenInfoContactModel(listA, listB);
System.out.println("the differce is: "+diff.getDifferentsContacts());
}
}

View File

@ -0,0 +1,155 @@
package org.gcube.portlets.widgets.workspacesharingwidget.server.util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
public class ScopeUtilFilter {
private static final String SCOPE_SEPARATOR = "/";
private String scopeRoot = null;
public static Logger logger = Logger.getLogger(ScopeUtilFilter.class);
public Map<String, String> hashScopesFiltered = new HashMap<String, String>();
public static final String ALLSCOPE = "All spaces";
public static final String IDALLSCOPE = "ID All spaces";
public ScopeUtilFilter(String scopeName) {
if(scopeName!=null){
String[] scopes = scopeName.split(SCOPE_SEPARATOR);
if(scopes!=null && scopes.length>1){
scopeRoot = SCOPE_SEPARATOR+scopes[1];
logger.trace("found root "+scopeRoot);
}
else{
logger.warn("root scope not found!");
scopeRoot = SCOPE_SEPARATOR;
}
hashScopesFiltered.put(ALLSCOPE, IDALLSCOPE); //PUT DEFAULT ID ALL SCOPE
}
}
public List<String> convertListScopeToPortlet(List<String> listScopes){
logger.trace("Scope converting...");
List<String> scopesConverted = new ArrayList<String>();
scopesConverted.add(ALLSCOPE);
if(scopeRoot.compareTo(SCOPE_SEPARATOR)==0){
logger.warn("root scope is '"+SCOPE_SEPARATOR+"' return list scopes passed in input");
return listScopes;
}
for (String scope : listScopes) {
if(scope.compareTo(scopeRoot)==0){ //CASE SCOPE IS ROOT
logger.trace("found scope root "+scope+" added to list without converting");
hashScopesFiltered.put(scopeRoot, scopeRoot);
scopesConverted.add(scopeRoot);
} else{
int index = scope.indexOf(scopeRoot,0);
int start = index+scopeRoot.length();
int end = scope.length();
//DEBUG
// System.out.println("\n\n ");
// System.out.println("index "+index);
// System.out.println("start "+start);
// System.out.println("end "+end);
if(index!=-1){ //CASE SCOPE ROOT IS FOUND
String filerString = scope.substring(index+start, scope.length());
hashScopesFiltered.put(filerString, scope);
scopesConverted.add(filerString);
logger.trace("scope "+scope+ " is converted in: "+filerString);
}else{ //CASE SCOPE ROOT NOT IS FOUND
logger.warn("scope "+scope + " was reject from filter");
}
}
}
logger.trace("Scope converting was completed");
return scopesConverted;
}
public String getPortalScopeFromFilteredScope(String scope){
String portalScope = hashScopesFiltered.get(scope);
if(portalScope==null){
logger.warn("scope not found in scope fiter, return root scope "+scopeRoot);
return scopeRoot;
}
return portalScope;
}
public Map<String, String> getHashScopesFiltered() {
return hashScopesFiltered;
}
//TEST
private void printScopeName(String scopeName){
String[] scopes = scopeName.split(SCOPE_SEPARATOR);
for (String scope : scopes) {
System.out.println("scope split: "+scope);
}
}
private void printScopes(){
for (String key : hashScopesFiltered.keySet()) {
System.out.println("Scope found: "+ hashScopesFiltered.get(key) +" with key: "+ key);
}
}
public String getScopeRoot() {
return scopeRoot;
}
public static void main(String[] args) {
String scope = "/gcube";
List<String> listTest = Arrays.asList(new String[]{"/gcube/devsec/devre", "/gcube/devsec","/gcube/devsec/devNEXT", "/", "/gcub", "/gcube"});
ScopeUtilFilter filter = new ScopeUtilFilter(scope);
System.out.println("scope root is: "+filter.getScopeRoot());
filter.convertListScopeToPortlet(listTest);
System.out.println("get portal scope "+filter.getPortalScopeFromFilteredScope("/devsec"));
filter.printScopes();
}
}

View File

@ -0,0 +1,115 @@
package org.gcube.portlets.widgets.workspacesharingwidget.server.util;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
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
// logger.trace("Finding full name for: "+portalLogin);
if(portalLogin==null)
return "";
if (portalLogin.compareTo(WsUtil.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) {
logger.error("An error occurred in getUserFullName "+ume,ume);
}catch (Exception e) {
logger.error("An error occurred in getUserFullName "+e,e);
logger.warn("Return portal login "+portalLogin);
return portalLogin;
}
if (curr != null){
// logger.trace("Return "+curr.getFullname() +" full name for: "+portalLogin);
return curr.getFullname();
}
}else{
logger.trace("Return "+WsUtil.TEST_USER_FULL_NAME +" full name for: "+portalLogin);
return WsUtil.TEST_USER_FULL_NAME;
}
logger.trace("Return empty full name for: "+portalLogin);
return "";
}
public static List<String> getListLoginByInfoContactModel(List<InfoContactModel> listContacts){
List<String> listUsers = new ArrayList<String>();
for (InfoContactModel infoContactModel : listContacts) {
listUsers.add(infoContactModel.getLogin());
}
return listUsers;
}
public static String separateUsersNamesToComma(List<InfoContactModel> 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<String> 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;
}
}

View File

@ -0,0 +1,257 @@
/**
*
*/
package org.gcube.portlets.widgets.workspacesharingwidget.server.util;
import javax.servlet.http.HttpSession;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager;
import org.gcube.applicationsupportlayer.social.NotificationsManager;
import org.gcube.common.homelibrary.home.HomeLibrary;
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portlets.widgets.workspacesharingwidget.server.GWTWorkspaceSharingBuilder;
import org.gcube.portlets.widgets.workspacesharingwidget.server.notifications.NotificationsProducer;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @Feb 18, 2014
*
*/
public class WsUtil {
public static final String USERNAME_ATTRIBUTE = ScopeHelper.USERNAME_ATTRIBUTE;
public static final String FOLDERIMPORTER_ATTRIBUTE = "FOLDER_IMPORTER";
public static final String METADATACONVERTER_ATTRIBUTE = "METADATA_CONVERTER";
public static final String WORKSPACE_EVENT_COLLECTOR_ATTRIBUTE = "EVENT_COLLECTOR";
public static final String WORKSPACEBUILDER_ATTRIBUTE = "WORKSPACEBUILDER";
public static final String NOTIFICATION_MANAGER = "NOTIFICATION_MANAGER";
public static final String NOTIFICATION_PRODUCER = "NOTIFICATION_PRODUCER";
public static final String WS_RUN_IN_TEST_MODE = "WS_RUN_IN_TEST_MODE";
public static final String WORKSPACE_SCOPE_UTIL = "WORKSPACE_SCOPE_UTIL";
public static final String URL_SHORTENER_SERVICE = "URL_SHORTENER_SERVICE";
public static final String URI_RESOLVER_SERVICE = "URI_RESOLVER_SERVICE";
public static final String NOTIFICATION_PORTLET_CLASS_ID = "org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl"; //IN DEV
// public static final String TEST_SCOPE = "/gcube/devsec";
// public static final String TEST_USER = "pasquale.pagano";
public static final String TEST_SCOPE = "/gcube/devsec";
// public static final String TEST_USER = "federico.defaveri";
// public static final String TEST_USER = "massimiliano.assante";
// public static final String TEST_USER = "pasquale.pagano";
// public static final String TEST_USER = "francesco.mangiacrapa";
// public static final String TEST_USER_FULL_NAME = "Francesco Mangiacrapa";
// public static final String TEST_USER = "aureliano.gentile";
public static final String TEST_USER = "test.user";
// public static final String TEST_USER = "antonio.gioia";
public static final String TEST_USER_FULL_NAME = "Test User";
protected static Logger logger = Logger.getLogger(WsUtil.class);
public static boolean withoutPortal = false;
public static ASLSession getAslSession(HttpSession httpSession)
{
String sessionID = httpSession.getId();
String user = (String) httpSession.getAttribute(USERNAME_ATTRIBUTE);
ASLSession session;
if (user == null) {
/*USE ANOTHER ACCOUNT (OTHERWHISE BY TEST_USER) FOR RUNNING
* COMMENT THIS IN DEVELOP ENVIROMENT (UNCOMMENT IN PRODUCTION)*/
user=TEST_USER;
//UNCOMMENT THIS IN DEVELOP ENVIROMENT
// user = "francesco.mangiacrapa";
logger.warn("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND - PORTLETS STARTING WITH FOLLOWING SETTINGS:");
logger.warn("session id: "+sessionID);
logger.warn("TEST_USER: "+user);
logger.warn("TEST_SCOPE: "+TEST_SCOPE);
logger.warn("USERNAME_ATTRIBUTE: "+USERNAME_ATTRIBUTE);
session = SessionManager.getInstance().getASLSession(sessionID, user);
session.setScope(TEST_SCOPE);
//MANDATORY FOR SOCIAL LIBRARY
session.setUserAvatarId(user + "Avatar");
session.setUserFullName(TEST_USER_FULL_NAME);
session.setUserEmailAddress(user + "@mail.test");
//SET HTTP SESSION ATTRIBUTE
httpSession.setAttribute(USERNAME_ATTRIBUTE, user);
withoutPortal = true;
return session;
}else if(user.compareToIgnoreCase(TEST_USER)==0){
withoutPortal = true;
//COMMENT THIS IN PRODUCTION ENVIROMENT
// }else if(user.compareToIgnoreCase("francesco.mangiacrapa")==0){
//
// withoutPortal = true;
//// END UNCOMMENT
}else{
withoutPortal = false;
}
return SessionManager.getInstance().getASLSession(sessionID, user);
}
/**
*
* @param httpSession
* @return true if current username into ASL session is WsUtil.TEST_USER, false otherwise
* @throws Exception
*/
public static boolean isSessionExpired(HttpSession httpSession) throws Exception {
logger.trace("workspace session validating...");
//READING USERNAME FROM ASL SESSION
String userUsername = getAslSession(httpSession).getUsername();
boolean isTestUser = userUsername.compareTo(WsUtil.TEST_USER)==0;
//TODO UNCOMMENT THIS FOR RELEASE
logger.trace("Is "+WsUtil.TEST_USER+" test user? "+isTestUser);
if(isTestUser){
logger.error("workspace session is expired! username is: "+WsUtil.TEST_USER);
return true; //is TEST_USER, session is expired
}
logger.trace("workspace session is valid! current username is: "+userUsername);
return false;
}
public static Workspace getWorkspace(final HttpSession httpSession) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException
{
logger.trace("Get Workspace");
final ASLSession session = getAslSession(httpSession);
logger.trace("ASLSession scope: "+session.getScope() + " username: "+session.getUsername());
ScopeProvider.instance.set(session.getScope());
logger.trace("Scope provider instancied");
Workspace workspace = HomeLibrary.getUserWorkspace(session.getUsername());
if (session.getAttribute(WORKSPACEBUILDER_ATTRIBUTE) == null)
{
logger.trace("Initializing the workspace area builder");
GWTWorkspaceSharingBuilder builder = new GWTWorkspaceSharingBuilder();
//ADDED 03/09/2013
builder.setUserLogged(new InfoContactModel(session.getUsername(), session.getUsername(), session.getUserFullName()));
session.setAttribute(WORKSPACEBUILDER_ATTRIBUTE, builder);
}
return workspace;
}
public static NotificationsManager getNotificationManager(ASLSession session)
{
NotificationsManager notifMng = (NotificationsManager) session.getAttribute(NOTIFICATION_MANAGER);
if (notifMng == null) {
try{
logger.trace("Create new NotificationsManager for user: "+session.getUsername());
logger.trace("New ApplicationNotificationsManager with portlet class name: "+NOTIFICATION_PORTLET_CLASS_ID);
notifMng = new ApplicationNotificationsManager(session, NOTIFICATION_PORTLET_CLASS_ID);
session.setAttribute(NOTIFICATION_MANAGER, notifMng);
}catch (Exception e) {
logger.error("An error occurred instancing ApplicationNotificationsManager for user: "+session.getUsername(),e);
}
}
return notifMng;
}
public static NotificationsProducer getNotificationProducer(ASLSession session)
{
NotificationsProducer notifProducer = (NotificationsProducer) session.getAttribute(NOTIFICATION_PRODUCER);
if (notifProducer == null) {
logger.trace("Create new Notification Producer for user: "+session.getUsername());
notifProducer = new NotificationsProducer(session);
session.setAttribute(NOTIFICATION_PRODUCER, notifProducer);
}
return notifProducer;
}
public static String getUserId(HttpSession httpSession) {
ASLSession session = getAslSession(httpSession);
return session.getUsername();
}
public static boolean isVRE(ASLSession session){
String currentScope = session.getScopeName();
int slashCount = StringUtils.countMatches(currentScope, "/");
if(slashCount < 3){
logger.trace("currentScope is not VRE");
return false;
}
logger.trace("currentScope is VRE");
return true;
}
public static ScopeUtilFilter getScopeUtilFilter(HttpSession httpSession){
ASLSession session = getAslSession(httpSession);
ScopeUtilFilter scopeUtil = null;
try{
scopeUtil = (ScopeUtilFilter) session.getAttribute(WsUtil.WORKSPACE_SCOPE_UTIL);
if(scopeUtil==null){
scopeUtil = new ScopeUtilFilter(session.getScopeName());
}
}catch (Exception e) {
logger.error("an error occurred in getscope filter "+e);
}
return scopeUtil;
}
/**
* @param session
* @return
*/
public static GWTWorkspaceSharingBuilder getGWTWorkspaceSharingBuilder(
HttpSession session) {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -0,0 +1,222 @@
package org.gcube.portlets.widgets.workspacesharingwidget.shared;
import java.io.Serializable;
import java.util.List;
import com.extjs.gxt.ui.client.data.BaseModelData;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @Feb 25, 2014
*
*/
public class FileModel extends BaseModelData implements Serializable {
/**
*
*/
private static final long serialVersionUID = 7291843683961579349L;
private static final String DIRECTORYDESCRIPTION = "DIRECTORYDESCRIPTION";
private static final String PARENT = "PARENT";
private static final String OWNER = "OWNER";
private static final String OWNERFULLNAME = "OWNERFULLNAME";
private static final String ISSHARED = "ISSHARED";
private static final String SHAREUSERS = "SHAREUSERS";
private static final String ISDIRECTORY = "ISDIRECTORY";
private static final String IDENTIFIER = "IDENTIFIER";
private static final String TYPE = "TYPE";
private static final String NAME = "NAME";
protected InfoContactModel infoContacts;
protected boolean isRoot = false;
protected boolean isVreFolder;
protected FileModel() {
}
/**
*
* @param identifier
* @param name
* @param parent
* @param isDirectory
* @param isShared
*/
public FileModel(String identifier, String name, FileModel parent, boolean isDirectory, boolean isShared) {
setIdentifier(identifier);
setName(name);
setParentFileModel(parent);
setIsDirectory(isDirectory);
setShared(isShared);
}
/**
* USED FOR ATTACHMENTS AND FolderBulkCreator
*
* @param identifier
* @param name
* @param isDirectory
*/
public FileModel(String identifier, String name, boolean isDirectory) {
setIdentifier(identifier);
setName(name);
setIsDirectory(isDirectory);
}
public void setDescription(String description) {
set(DIRECTORYDESCRIPTION, description);
}
public String getDescription() {
return get(DIRECTORYDESCRIPTION);
}
public void setParentFileModel(FileModel parent) {
set(PARENT, parent);
}
/**
* Status values ConstantsExplorer.FOLDERNOTLOAD = "notload";
* ConstantsExplorer.FOLDERLOADED = "loaded";
*
* @param status
*/
public void setStatus(String status) {
set("status", status);
}
// public void resetIcons(){
// set(ConstantsExplorer.ICON,null);
// set(ConstantsExplorer.ABSTRACTICON, null);
// }
public void setOwner(InfoContactModel owner) {
set(OWNER, owner);
// if(owner!=null)
// set(ConstantsExplorer.OWNERFULLNAME, owner.getName());
}
public void setOwnerFullName(String fullName) {
set(OWNERFULLNAME, fullName);
}
// TODO Accounting
public InfoContactModel getOwner() {
return (InfoContactModel) get(OWNER);
}
public String getOwnerFullName() {
return get(OWNERFULLNAME);
}
public void setSharingValue(boolean isShared,
List<InfoContactModel> listShareUsers) {
set(ISSHARED, isShared);
set(SHAREUSERS, listShareUsers);
}
@SuppressWarnings("unchecked")
public List<InfoContactModel> getListUserSharing() {
return (List<InfoContactModel>) get(SHAREUSERS);
}
public void setListShareUser(List<InfoContactModel> listShareUsers) {
set(SHAREUSERS, listShareUsers);
}
public boolean isShared() {
return (Boolean) get(ISSHARED);
}
public boolean isRoot() {
return isRoot;
}
public void setIsRoot(boolean isRoot) {
this.isRoot = isRoot;
}
public String getStatus() {
return get("status");
}
private void setIsDirectory(boolean flag) {
set(ISDIRECTORY, flag);
}
public void setIdentifier(String identifier) {
set(IDENTIFIER, identifier);
}
public String getIdentifier() {
return get(IDENTIFIER);
}
private void setName(String name) {
set(NAME, name);
}
public String getName() {
return get(NAME);
}
public FileModel getParentFileModel() {
return get(PARENT);
}
public boolean isDirectory() {
return (Boolean) get(ISDIRECTORY);
}
@Override
public boolean equals(Object obj) {
if (obj != null && obj instanceof FileModel) {
FileModel mobj = (FileModel) obj;
return getIdentifier().equals(mobj.getIdentifier());
}
return super.equals(obj);
}
/**
* @param isShared
* the isShared to set
*/
public void setShared(boolean isShared) {
set(ISSHARED, isShared);
}
/**
* It's: folder, mime type or unknown
*
* @param type
*/
public void setType(String type) {
set(TYPE, type);
}
public String getType() {
return get(TYPE);
}
public boolean isVreFolder() {
return isVreFolder;
}
public void setVreFolder(boolean isVreFolder) {
this.isVreFolder = isVreFolder;
}
}

View File

@ -0,0 +1,33 @@
package org.gcube.portlets.widgets.workspacesharingwidget.shared;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*
*/
public class FolderModel extends FileModel {
/**
*
*/
private static final long serialVersionUID = 8634086763244262855L;
public FolderModel() {
}
public FolderModel(String identifier, String name, FileModel parent, boolean isDirectory, boolean isShared, boolean isVreFolder) {
super(identifier, name, parent, isDirectory, isShared);
super.setVreFolder(isVreFolder);
}
public FolderModel(String identifier, String name, boolean isDirectory, boolean isVreFolder) {
super(identifier, name, isDirectory);
super.setVreFolder(isVreFolder);
}
@Override
public String toString() {
return super.toString();
}
}

View File

@ -0,0 +1,81 @@
package org.gcube.portlets.widgets.workspacesharingwidget.shared;
import java.io.Serializable;
import java.util.Comparator;
import com.extjs.gxt.ui.client.data.BaseModelData;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*
*/
public class InfoContactModel extends BaseModelData implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1598054293247763508L;
protected static final String ID = "id";
public static final String FULLNAME = "fullname";
public static final String LOGIN = "login";
public InfoContactModel() {}
public InfoContactModel(String id, String login, String fullName) {
setId(id);
setLogin(login);
setName(fullName);
}
public void setName(String name) {
set(FULLNAME,name);
}
public String getName(){
return get(FULLNAME);
}
public String getId() {
return get(ID);
}
public void setId(String id) {
set(ID, id);
}
public String getLogin() {
return get(LOGIN);
}
public void setLogin(String login) {
set(LOGIN, login);
}
public static Comparator<InfoContactModel> COMPARATOR = new Comparator<InfoContactModel>() {
// This is where the sorting happens.
public int compare(InfoContactModel o1, InfoContactModel o2) {
return o1.getName().compareToIgnoreCase(o2.getName());
}
};
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("InfoContactModel [getName()=");
builder.append(getName());
builder.append(", getId()=");
builder.append(getId());
builder.append(", getLogin()=");
builder.append(getLogin());
builder.append("]");
return builder.toString();
}
}

View File

@ -0,0 +1,102 @@
package org.gcube.portlets.widgets.workspacesharingwidget.shared;
import java.io.Serializable;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @Feb 21, 2014
*
*/
public class WorkspaceACL implements Serializable{
/**
*
*/
private static final long serialVersionUID = 707825511378778432L;
private String id;
private String label;
private boolean defaultValue;
private USER_TYPE userType;
private String description;
public enum USER_TYPE{ADMINISTRATOR, GROUP, OWNER, OTHER};
public WorkspaceACL(String id, String label, boolean defaultValue, USER_TYPE userType, String description) {
super();
this.id = id;
this.label = label;
this.defaultValue = defaultValue;
this.userType = userType;
this.description = description;
}
public WorkspaceACL() {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public boolean getDefaultValue() {
return defaultValue;
}
public void setDefaultValue(boolean defaultValue) {
this.defaultValue = defaultValue;
}
public USER_TYPE getUserType() {
return userType;
}
public void setUserType(USER_TYPE userType) {
this.userType = userType;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("WorkspaceACL [id=");
builder.append(id);
builder.append(", label=");
builder.append(label);
builder.append(", defaultValue=");
builder.append(defaultValue);
builder.append(", userType=");
builder.append(userType);
builder.append(", description=");
builder.append(description);
builder.append("]");
return builder.toString();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 831 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 989 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 953 B