3277: Workspace Sharing Widget enhancement in order to display short VREs name
Task-Url: https://support.d4science.org/issues/3277 Updated pom version at 1.6.0 Realized solution to implement the above task git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-sharing-widget@128085 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
3db6e37121
commit
153942ce28
2
pom.xml
2
pom.xml
|
@ -14,7 +14,7 @@
|
||||||
<groupId>org.gcube.portlets.widgets</groupId>
|
<groupId>org.gcube.portlets.widgets</groupId>
|
||||||
<artifactId>workspace-sharing-widget</artifactId>
|
<artifactId>workspace-sharing-widget</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<version>1.5.1-SNAPSHOT</version>
|
<version>1.6.0-SNAPSHOT</version>
|
||||||
<name>gCube Workspace Sharing Widget</name>
|
<name>gCube Workspace Sharing Widget</name>
|
||||||
<description>
|
<description>
|
||||||
gCube Workspace Sharing Widget allows users to share gCube Workspace items
|
gCube Workspace Sharing Widget allows users to share gCube Workspace items
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.widgets.workspacesharingwidget.client;
|
package org.gcube.portlets.widgets.workspacesharingwidget.client;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ import com.google.gwt.core.client.GWT;
|
||||||
/**
|
/**
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
* @Feb 25, 2014
|
* @Feb 25, 2014
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class WorkspaceSmartSharingController {
|
public class WorkspaceSmartSharingController {
|
||||||
|
|
||||||
|
@ -38,24 +38,24 @@ public class WorkspaceSmartSharingController {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param file - a fake file to display the field name ("filename") into dialog
|
* @param file - a fake file to display the field name ("filename") into dialog
|
||||||
* @param listAlreadySharedContact - list of already shared contacts to show into dialog
|
* @param listAlreadySharedContact - list of already shared contacts to show into dialog
|
||||||
*
|
*
|
||||||
* base constructor by default does not retrieve the groups
|
* base constructor by default does not retrieve the groups
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public WorkspaceSmartSharingController(FileModel file, List<CredentialModel> listAlreadySharedContact) {
|
public WorkspaceSmartSharingController(FileModel file, List<CredentialModel> listAlreadySharedContact) {
|
||||||
this(file, listAlreadySharedContact, false, false);
|
this(file, listAlreadySharedContact, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param file - a fake file to display the field name ("filename") into dialog
|
* @param file - a fake file to display the field name ("filename") into dialog
|
||||||
* @param listAlreadySharedContact - list of already shared contacts to show into dialog
|
* @param listAlreadySharedContact - list of already shared contacts to show into dialog
|
||||||
* @param readGroupsFromHL - if true, read group names from HL
|
* @param readGroupsFromHL - if true, read group names from HL
|
||||||
* @param readGroupsFromPortal - if true, read group names from Portal (as VRE)
|
* @param readGroupsFromPortal - if true, read group names from Portal (as VRE)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public WorkspaceSmartSharingController(FileModel file, List<CredentialModel> listAlreadySharedContact, boolean readGroupsFromHL, boolean readGroupsFromPortal) {
|
public WorkspaceSmartSharingController(FileModel file, List<CredentialModel> listAlreadySharedContact, boolean readGroupsFromHL, boolean readGroupsFromPortal) {
|
||||||
this.listAlreadySharedContact = listAlreadySharedContact;
|
this.listAlreadySharedContact = listAlreadySharedContact;
|
||||||
|
@ -67,13 +67,13 @@ public class WorkspaceSmartSharingController {
|
||||||
updateSharingDialog();
|
updateSharingDialog();
|
||||||
addListenersSharingDialog();
|
addListenersSharingDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Example of listeners
|
* Example of listeners
|
||||||
*/
|
*/
|
||||||
private void addListenersSharingDialog(){
|
private void addListenersSharingDialog(){
|
||||||
|
|
||||||
smartShare.getButtonById(Dialog.OK).addListener(Events.Select, new Listener<BaseEvent>() {
|
smartShare.getButtonById(Dialog.OK).addListener(Events.Select, new Listener<BaseEvent>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -81,41 +81,37 @@ public class WorkspaceSmartSharingController {
|
||||||
|
|
||||||
// if(smartShare.isValidForm(true)){
|
// if(smartShare.isValidForm(true)){
|
||||||
// //THAT'S OK
|
// //THAT'S OK
|
||||||
//
|
//
|
||||||
// smartShare.getSharedListUsers(); //@return the selected contacts (as InfoContactModel)
|
// smartShare.getSharedListUsers(); //@return the selected contacts (as InfoContactModel)
|
||||||
//
|
//
|
||||||
// smartShare.getSharedListUsersCredential(); //@return tthe selected contacts (as CredentialModel)
|
// smartShare.getSharedListUsersCredential(); //@return tthe selected contacts (as CredentialModel)
|
||||||
//
|
//
|
||||||
// for (InfoContactModel contact : smartShare.getSharedListUsers()) {
|
// for (InfoContactModel contact : smartShare.getSharedListUsers()) {
|
||||||
// System.out.println(contact);
|
// System.out.println(contact);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// for (CredentialModel credential : smartShare.getSharedListUsersCredential()) {
|
// for (CredentialModel credential : smartShare.getSharedListUsersCredential()) {
|
||||||
// System.out.println(credential);
|
// System.out.println(credential);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param fileModel
|
* @param fileModel
|
||||||
*/
|
*/
|
||||||
private void updateSharingDialog(){
|
private void updateSharingDialog(){
|
||||||
smartShare.unmask();
|
smartShare.unmask();
|
||||||
smartShare.updateSharingDialog(fileModel, listAlreadySharedContact);
|
smartShare.updateSharingDialog(fileModel, listAlreadySharedContact);
|
||||||
// dialogShareItem.show();
|
|
||||||
|
|
||||||
smartShare.layout();
|
smartShare.layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return SmartShare An extension of gxt dialog 2.2.5
|
* @return SmartShare An extension of gxt dialog 2.2.5
|
||||||
*/
|
*/
|
||||||
public SmartShare getSharingDialog() {
|
public SmartShare getSharingDialog() {
|
||||||
|
|
|
@ -35,13 +35,13 @@ import com.google.gwt.user.client.ui.FlexTable;
|
||||||
import com.google.gwt.user.client.ui.Label;
|
import com.google.gwt.user.client.ui.Label;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
* @Feb 27, 2014
|
* @Feb 27, 2014
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DialogShareWItem extends Dialog {
|
public class DialogShareWItem extends Dialog {
|
||||||
|
|
||||||
|
|
||||||
private int heightTextArea = 100;
|
private int heightTextArea = 100;
|
||||||
private TextField<String> txtName;
|
private TextField<String> txtName;
|
||||||
|
@ -56,31 +56,31 @@ public class DialogShareWItem extends Dialog {
|
||||||
private boolean showError = false;
|
private boolean showError = false;
|
||||||
private boolean readGroupsFromHL;
|
private boolean readGroupsFromHL;
|
||||||
private boolean readGroupsFromPortal;
|
private boolean readGroupsFromPortal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* By DEFAULT DOESN'T READ GROUPS FROM SERVER
|
* By DEFAULT DOESN'T READ GROUPS FROM SERVER
|
||||||
*/
|
*/
|
||||||
public DialogShareWItem() {
|
public DialogShareWItem() {
|
||||||
this(false, false);
|
this(false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param readGroupsFromHL
|
* @param readGroupsFromHL
|
||||||
* @param readGroupsFromPortal
|
* @param readGroupsFromPortal
|
||||||
*/
|
*/
|
||||||
public DialogShareWItem(boolean readGroupsFromHL, boolean readGroupsFromPortal) {
|
public DialogShareWItem(boolean readGroupsFromHL, boolean readGroupsFromPortal) {
|
||||||
this.readGroupsFromHL = readGroupsFromHL;
|
this.readGroupsFromHL = readGroupsFromHL;
|
||||||
this.readGroupsFromPortal = readGroupsFromPortal;
|
this.readGroupsFromPortal = readGroupsFromPortal;
|
||||||
suggestPanel = new MultiValuePanel(userStore, readGroupsFromHL, readGroupsFromPortal);
|
suggestPanel = new MultiValuePanel(userStore, readGroupsFromHL, readGroupsFromPortal);
|
||||||
initLayout();
|
initLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private List<InfoContactModel> listAlreadyShared = new ArrayList<InfoContactModel>(){
|
private List<InfoContactModel> listAlreadyShared = new ArrayList<InfoContactModel>(){
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -89,41 +89,41 @@ public class DialogShareWItem extends Dialog {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Object o) {
|
public boolean contains(Object o) {
|
||||||
|
|
||||||
if(o==null)
|
if(o==null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
InfoContactModel contact = (InfoContactModel) o;
|
InfoContactModel contact = (InfoContactModel) o;
|
||||||
|
|
||||||
for (int i = 0; i < listAlreadyShared.size(); i++){
|
for (int i = 0; i < listAlreadyShared.size(); i++){
|
||||||
if (contact.getName().compareTo(listAlreadyShared.get(i).getName())==0)
|
if (contact.getName().compareTo(listAlreadyShared.get(i).getName())==0)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use to modify a shared folder or share an existing folder
|
* Use to modify a shared folder or share an existing folder
|
||||||
* @param fileModel
|
* @param fileModel
|
||||||
* @param type
|
* @param type
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void updateSharingDialog(FileModel fileModel, final boolean shareOnlyOwner, final ACL_TYPE defaultACL){
|
public void updateSharingDialog(FileModel fileModel, final boolean shareOnlyOwner, final ACL_TYPE defaultACL){
|
||||||
this.fileToShare = fileModel;
|
this.fileToShare = fileModel;
|
||||||
|
|
||||||
String heading = "Share workspace";
|
String heading = "Share workspace";
|
||||||
if(fileModel.isDirectory())
|
if(fileModel.isDirectory())
|
||||||
heading+=" folder: ";
|
heading+=" folder: ";
|
||||||
else
|
else
|
||||||
heading+= " item: ";
|
heading+= " item: ";
|
||||||
|
|
||||||
setHeading(heading+fileModel.getName());
|
setHeading(heading+fileModel.getName());
|
||||||
|
|
||||||
txtName = new TextField<String>();
|
txtName = new TextField<String>();
|
||||||
|
@ -132,7 +132,7 @@ public class DialogShareWItem extends Dialog {
|
||||||
txtName.setReadOnly(true);
|
txtName.setReadOnly(true);
|
||||||
txtName.setAutoValidate(true);
|
txtName.setAutoValidate(true);
|
||||||
txtName.setFieldLabel("Folder Name");
|
txtName.setFieldLabel("Folder Name");
|
||||||
|
|
||||||
txtOwner = new TextField<String>();
|
txtOwner = new TextField<String>();
|
||||||
txtOwner.setAllowBlank(true);
|
txtOwner.setAllowBlank(true);
|
||||||
txtOwner.setValue("");
|
txtOwner.setValue("");
|
||||||
|
@ -143,7 +143,7 @@ public class DialogShareWItem extends Dialog {
|
||||||
textAreaDescription.setFieldLabel("Description");
|
textAreaDescription.setFieldLabel("Description");
|
||||||
textAreaDescription.setHeight(heightTextArea);
|
textAreaDescription.setHeight(heightTextArea);
|
||||||
textAreaDescription.setWidth(380);
|
textAreaDescription.setWidth(380);
|
||||||
|
|
||||||
textAreaDescription.setValue(fileModel.getDescription());
|
textAreaDescription.setValue(fileModel.getDescription());
|
||||||
|
|
||||||
final LayoutContainer lc = new LayoutContainer();
|
final LayoutContainer lc = new LayoutContainer();
|
||||||
|
@ -162,17 +162,17 @@ public class DialogShareWItem extends Dialog {
|
||||||
|
|
||||||
flexTable.setWidget(1, 0, new Label("Add more"));
|
flexTable.setWidget(1, 0, new Label("Add more"));
|
||||||
flexTable.setWidget(1, 1, buttonMultiDrag);
|
flexTable.setWidget(1, 1, buttonMultiDrag);
|
||||||
|
|
||||||
Label labelDescription = new Label("Description");
|
Label labelDescription = new Label("Description");
|
||||||
flexTable.setWidget(2, 0, labelDescription);
|
flexTable.setWidget(2, 0, labelDescription);
|
||||||
flexTable.setWidget(2, 1, textAreaDescription);
|
flexTable.setWidget(2, 1, textAreaDescription);
|
||||||
|
|
||||||
|
|
||||||
hpPermission = new HorizontalPanel();
|
hpPermission = new HorizontalPanel();
|
||||||
hpPermission.setVerticalAlign(VerticalAlignment.MIDDLE);
|
hpPermission.setVerticalAlign(VerticalAlignment.MIDDLE);
|
||||||
Label labelProperty = new Label("Permissions");
|
Label labelProperty = new Label("Permissions");
|
||||||
hpPermission.add(labelProperty);
|
hpPermission.add(labelProperty);
|
||||||
|
|
||||||
WorkspaceSharingController.rpcWorkspaceSharingService.getACLs(new AsyncCallback<List<WorkspaceACL>>() {
|
WorkspaceSharingController.rpcWorkspaceSharingService.getACLs(new AsyncCallback<List<WorkspaceACL>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -191,35 +191,35 @@ public class DialogShareWItem extends Dialog {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
lc.add(flexTable);
|
lc.add(flexTable);
|
||||||
if(hpPermission!=null)
|
if(hpPermission!=null)
|
||||||
lc.add(hpPermission);
|
lc.add(hpPermission);
|
||||||
lc.mask();
|
lc.mask();
|
||||||
|
|
||||||
userStore.getListSharedUserByFolderId(fileModel.getIdentifier(), new AsyncCallback<List<InfoContactModel>>() {
|
userStore.getListSharedUserByFolderId(fileModel.getIdentifier(), new AsyncCallback<List<InfoContactModel>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<InfoContactModel> result) {
|
public void onSuccess(List<InfoContactModel> result) {
|
||||||
|
|
||||||
for (InfoContactModel infoContactModel : result) {
|
for (InfoContactModel infoContactModel : result) {
|
||||||
if(infoContactModel.getName()!=null){
|
if(infoContactModel.getName()!=null){
|
||||||
listAlreadyShared.add(infoContactModel);
|
listAlreadyShared.add(infoContactModel);
|
||||||
suggestPanel.addRecipient(infoContactModel.getName(),false);
|
suggestPanel.addRecipient(infoContactModel.getName(),false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lc.unmask();
|
lc.unmask();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
lc.unmask();
|
lc.unmask();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
userStore.getOwner(fileModel.getIdentifier(), new AsyncCallback<InfoContactModel>() {
|
userStore.getOwner(fileModel.getIdentifier(), new AsyncCallback<InfoContactModel>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -230,7 +230,7 @@ public class DialogShareWItem extends Dialog {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(InfoContactModel result) {
|
public void onSuccess(InfoContactModel result) {
|
||||||
txtOwner.setValue(result.getName());
|
txtOwner.setValue(result.getName());
|
||||||
|
|
||||||
if(shareOnlyOwner){
|
if(shareOnlyOwner){
|
||||||
permissionControl(result.getLogin(), true);
|
permissionControl(result.getLogin(), true);
|
||||||
}
|
}
|
||||||
|
@ -242,14 +242,14 @@ public class DialogShareWItem extends Dialog {
|
||||||
add(txtOwner);
|
add(txtOwner);
|
||||||
add(lc);
|
add(lc);
|
||||||
addListners();
|
addListners();
|
||||||
|
|
||||||
if(shareOnlyOwner)
|
if(shareOnlyOwner)
|
||||||
enableFormDialog(false); //FORM IS DISABLED BY DEFAULT
|
enableFormDialog(false); //FORM IS DISABLED BY DEFAULT
|
||||||
}
|
}
|
||||||
|
|
||||||
private void permissionControl(String owner, boolean showAlert){
|
private void permissionControl(String owner, boolean showAlert){
|
||||||
GWT.log("Permission control compare between owner: "+owner +" and my login: "+WorkspaceSharingController.getMyLogin());
|
GWT.log("Permission control compare between owner: "+owner +" and my login: "+WorkspaceSharingController.getMyLogin());
|
||||||
|
|
||||||
if(WorkspaceSharingController.getMyLogin().compareToIgnoreCase(owner)!=0){
|
if(WorkspaceSharingController.getMyLogin().compareToIgnoreCase(owner)!=0){
|
||||||
enableFormDialog(false);
|
enableFormDialog(false);
|
||||||
if(showAlert){
|
if(showAlert){
|
||||||
|
@ -259,19 +259,19 @@ public class DialogShareWItem extends Dialog {
|
||||||
enableFormDialog(true);
|
enableFormDialog(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see com.extjs.gxt.ui.client.widget.Window#afterShow()
|
* @see com.extjs.gxt.ui.client.widget.Window#afterShow()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void afterShow() {
|
protected void afterShow() {
|
||||||
super.afterShow();
|
super.afterShow();
|
||||||
|
|
||||||
if(showError){
|
if(showError){
|
||||||
MessageBox.alert("Permission denied", "You have no permissions to change sharing. You are not owner of \""+txtName.getValue()+"\"", null);
|
MessageBox.alert("Permission denied", "You have no permissions to change sharing. You are not owner of \""+txtName.getValue()+"\"", null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableFormDialog(boolean bool){
|
private void enableFormDialog(boolean bool){
|
||||||
getButtonById(Dialog.OK).setEnabled(bool);
|
getButtonById(Dialog.OK).setEnabled(bool);
|
||||||
buttonMultiDrag.setEnabled(bool);
|
buttonMultiDrag.setEnabled(bool);
|
||||||
|
@ -279,21 +279,21 @@ public class DialogShareWItem extends Dialog {
|
||||||
if(permission!=null)
|
if(permission!=null)
|
||||||
permission.setEnabled(bool);
|
permission.setEnabled(bool);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAsError(String message){
|
public void setAsError(String message){
|
||||||
enableFormDialog(false);
|
enableFormDialog(false);
|
||||||
this.add(new Html("<br/> <p style=\"color:red; font-family:verdana, arial; font-size:14px;\">"+message+"</p>"));
|
this.add(new Html("<br/> <p style=\"color:red; font-family:verdana, arial; font-size:14px;\">"+message+"</p>"));
|
||||||
this.layout();
|
this.layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public FileModel getFileToShare() {
|
public FileModel getFileToShare() {
|
||||||
return fileToShare;
|
return fileToShare;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initLayout(){
|
public void initLayout(){
|
||||||
FormLayout layout = new FormLayout();
|
FormLayout layout = new FormLayout();
|
||||||
layout.setLabelWidth(90);
|
layout.setLabelWidth(90);
|
||||||
|
@ -305,7 +305,7 @@ public class DialogShareWItem extends Dialog {
|
||||||
setWidth(ConstantsSharing.WIDTH_DIALOG);
|
setWidth(ConstantsSharing.WIDTH_DIALOG);
|
||||||
setHeight(ConstantsSharing.HEIGHT_DIALOG);
|
setHeight(ConstantsSharing.HEIGHT_DIALOG);
|
||||||
setResizable(true);
|
setResizable(true);
|
||||||
setButtonAlign(HorizontalAlignment.CENTER);
|
setButtonAlign(HorizontalAlignment.CENTER);
|
||||||
setButtons(Dialog.OKCANCEL);
|
setButtons(Dialog.OKCANCEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ public class DialogShareWItem extends Dialog {
|
||||||
|
|
||||||
|
|
||||||
public void addListners(){
|
public void addListners(){
|
||||||
|
|
||||||
this.getButtonById(Dialog.CANCEL).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
this.getButtonById(Dialog.CANCEL).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -325,8 +325,8 @@ public class DialogShareWItem extends Dialog {
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/*this.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
/*this.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -334,91 +334,87 @@ public class DialogShareWItem extends Dialog {
|
||||||
if(isValidForm(true))
|
if(isValidForm(true))
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
|
|
||||||
buttonMultiDrag.addClickHandler(new ClickHandler() {
|
buttonMultiDrag.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
final DialogMultiDragContact dialog = new DialogMultiDragContact(true,true);
|
final DialogMultiDragContact dialog = new DialogMultiDragContact(true,true);
|
||||||
final MultiDragContact multiDrag = dialog.getMultiDrag();
|
final MultiDragContact multiDrag = dialog.getMultiDrag();
|
||||||
dialog.show();
|
dialog.show();
|
||||||
|
|
||||||
List<InfoContactModel> exclusiveContacts = userStore.getExclusiveContactsFromAllContact(suggestPanel.getSelectedUser());
|
List<InfoContactModel> exclusiveContacts = userStore.getExclusiveContactsFromAllContact(suggestPanel.getSelectedUser());
|
||||||
multiDrag.addSourceContacts(exclusiveContacts);
|
multiDrag.addSourceContacts(exclusiveContacts);
|
||||||
|
|
||||||
|
|
||||||
for (InfoContactModel infoContactModel : suggestPanel.getSelectedUser()) {
|
for (InfoContactModel infoContactModel : suggestPanel.getSelectedUser()) {
|
||||||
if(!listAlreadyShared.contains(infoContactModel))
|
if(!listAlreadyShared.contains(infoContactModel))
|
||||||
multiDrag.addTargetContact(infoContactModel);
|
multiDrag.addTargetContact(infoContactModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
multiDrag.addAlreadySharedContacts(suggestPanel.getSelectedUser());
|
multiDrag.addAlreadySharedContacts(suggestPanel.getSelectedUser());
|
||||||
|
|
||||||
// multiDrag.addTargetContacts(suggestPanel.getSelectedUser());
|
|
||||||
|
|
||||||
dialog.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
dialog.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void componentSelected(ButtonEvent ce) {
|
public void componentSelected(ButtonEvent ce) {
|
||||||
|
|
||||||
initSuggestContacts();
|
initSuggestContacts();
|
||||||
|
|
||||||
for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
|
for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
|
||||||
suggestPanel.addRecipient(infoContactModel.getName(),true);
|
suggestPanel.addRecipient(infoContactModel.getName(),true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
|
// for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
|
||||||
//
|
//
|
||||||
// if(!listAlreadySharedContains(infoContactModel))
|
// if(!listAlreadySharedContains(infoContactModel))
|
||||||
// suggestPanel.addRecipient(infoContactModel.getName(),true);
|
// suggestPanel.addRecipient(infoContactModel.getName(),true);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
suggestPanel.boxSetFocus();
|
suggestPanel.boxSetFocus();
|
||||||
|
|
||||||
// printSelectedUser();
|
// printSelectedUser();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean listAlreadySharedContains(InfoContactModel contact){
|
private boolean listAlreadySharedContains(InfoContactModel contact){
|
||||||
|
|
||||||
if(contact==null)
|
if(contact==null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (InfoContactModel ct : listAlreadyShared) {
|
for (InfoContactModel ct : listAlreadyShared) {
|
||||||
|
|
||||||
if(ct.getLogin().compareTo(contact.getLogin())==0){
|
if(ct.getLogin().compareTo(contact.getLogin())==0){
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//DEBUG
|
//DEBUG
|
||||||
private void printSelectedUser(){
|
private void printSelectedUser(){
|
||||||
|
|
||||||
System.out.println("SELETECTED USERS: ");
|
System.out.println("SELETECTED USERS: ");
|
||||||
for (InfoContactModel contact : suggestPanel.getSelectedUser())
|
for (InfoContactModel contact : suggestPanel.getSelectedUser())
|
||||||
System.out.println(contact);
|
System.out.println(contact);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initSuggestContacts(){
|
private void initSuggestContacts(){
|
||||||
|
|
||||||
suggestPanel.resetItemSelected();
|
suggestPanel.resetItemSelected();
|
||||||
|
|
||||||
for (InfoContactModel contact : listAlreadyShared) {
|
for (InfoContactModel contact : listAlreadyShared) {
|
||||||
suggestPanel.addRecipient(contact.getName(), false);
|
suggestPanel.addRecipient(contact.getName(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -428,35 +424,35 @@ public class DialogShareWItem extends Dialog {
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
if(textAreaDescription.getValue()==null)
|
if(textAreaDescription.getValue()==null)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
return textAreaDescription.getValue();
|
return textAreaDescription.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param displayAlert
|
* @param displayAlert
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isValidForm(boolean displayAlert){
|
public boolean isValidForm(boolean displayAlert){
|
||||||
|
|
||||||
if(!txtName.isValid()){
|
if(!txtName.isValid()){
|
||||||
if(displayAlert)
|
if(displayAlert)
|
||||||
MessageBox.alert("Attention", "Name must not be empty", null);
|
MessageBox.alert("Attention", "Name must not be empty", null);
|
||||||
txtName.focus();
|
txtName.focus();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getSharedListUsers().size()==0){
|
if(getSharedListUsers().size()==0){
|
||||||
if(displayAlert)
|
if(displayAlert)
|
||||||
MessageBox.alert("Attention", "You must pick at least one user with which share the folder", null);
|
MessageBox.alert("Attention", "You must pick at least one user with which share the folder", null);
|
||||||
suggestPanel.boxSetFocus();
|
suggestPanel.boxSetFocus();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorkspaceACL getSelectedACL(){
|
public WorkspaceACL getSelectedACL(){
|
||||||
if(permission!=null)
|
if(permission!=null)
|
||||||
return permission.getSelectedACL();
|
return permission.getSelectedACL();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing;
|
package org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing;
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
||||||
import com.extjs.gxt.ui.client.widget.MessageBox;
|
import com.extjs.gxt.ui.client.widget.MessageBox;
|
||||||
import com.extjs.gxt.ui.client.widget.form.TextField;
|
import com.extjs.gxt.ui.client.widget.form.TextField;
|
||||||
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
|
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
@ -34,12 +35,13 @@ import com.google.gwt.user.client.ui.FlexTable;
|
||||||
import com.google.gwt.user.client.ui.Label;
|
import com.google.gwt.user.client.ui.Label;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The Class SmartShare.
|
||||||
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
* @Mar 3, 2014
|
* @Mar 3, 2014
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class SmartShare extends Dialog implements SmartDialogInterface{
|
public class SmartShare extends Dialog implements SmartDialogInterface{
|
||||||
|
|
||||||
private TextField<String> txtName;
|
private TextField<String> txtName;
|
||||||
private FileModel fileToShare = null;
|
private FileModel fileToShare = null;
|
||||||
private UserStore userStore = new UserStore();
|
private UserStore userStore = new UserStore();
|
||||||
|
@ -47,66 +49,59 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
|
||||||
private Button buttonMultiDrag = new Button("Choose Contacts");
|
private Button buttonMultiDrag = new Button("Choose Contacts");
|
||||||
private boolean readGroupsFromHL;
|
private boolean readGroupsFromHL;
|
||||||
private boolean readGroupsFromPortal;
|
private boolean readGroupsFromPortal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SmartShare base constructor by default does not retrieve groupss
|
* SmartShare base constructor by default does not retrieve groupss.
|
||||||
*/
|
*/
|
||||||
public SmartShare() {
|
public SmartShare() {
|
||||||
this(false, false);
|
this(false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Instantiates a new smart share.
|
||||||
|
*
|
||||||
* @param readGroupsFromHL - if true read group names from HL
|
* @param readGroupsFromHL - if true read group names from HL
|
||||||
* @param readGroupsFromPortal - if true read group names from Portal (as VRE)
|
* @param readGroupsFromPortal - if true read group names from Portal (as VRE)
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public SmartShare(boolean readGroupsFromHL, boolean readGroupsFromPortal) {
|
public SmartShare(boolean readGroupsFromHL, boolean readGroupsFromPortal) {
|
||||||
this.readGroupsFromHL = readGroupsFromHL;
|
this.readGroupsFromHL = readGroupsFromHL;
|
||||||
this.readGroupsFromPortal = readGroupsFromPortal;
|
this.readGroupsFromPortal = readGroupsFromPortal;
|
||||||
suggestPanel = new MultiValuePanel(userStore, readGroupsFromHL, readGroupsFromPortal);
|
suggestPanel = new MultiValuePanel(userStore, readGroupsFromHL, readGroupsFromPortal);
|
||||||
initLayout();
|
initLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private List<InfoContactModel> listAlreadyShared = new ArrayList<InfoContactModel>(){
|
private List<InfoContactModel> listAlreadyShared = new ArrayList<InfoContactModel>(){
|
||||||
|
|
||||||
/**
|
private static final long serialVersionUID = -610980920163628336L;
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare Login
|
* Compare Login
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Object o) {
|
public boolean contains(Object o) {
|
||||||
|
|
||||||
if(o==null)
|
if(o==null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
InfoContactModel contact = (InfoContactModel) o;
|
InfoContactModel contact = (InfoContactModel) o;
|
||||||
|
|
||||||
for (int i = 0; i < listAlreadyShared.size(); i++){
|
for (int i = 0; i < listAlreadyShared.size(); i++){
|
||||||
if (contact.getName().compareTo(listAlreadyShared.get(i).getName())==0)
|
if (contact.getName().compareTo(listAlreadyShared.get(i).getName())==0)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use to modify a shared folder or share an existing folder
|
* Use to modify a shared folder or share an existing folder.
|
||||||
* @param fileModel
|
*
|
||||||
* @param type
|
* @param fileModel the file model
|
||||||
|
* @param listAlreadySharedContact the list already shared contact
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void updateSharingDialog(FileModel fileModel, List<CredentialModel> listAlreadySharedContact){
|
public void updateSharingDialog(FileModel fileModel, List<CredentialModel> listAlreadySharedContact){
|
||||||
this.fileToShare = fileModel;
|
this.fileToShare = fileModel;
|
||||||
String heading;
|
String heading;
|
||||||
|
@ -116,7 +111,7 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
|
||||||
heading+=" folder: ";
|
heading+=" folder: ";
|
||||||
else
|
else
|
||||||
heading+= " : ";
|
heading+= " : ";
|
||||||
|
|
||||||
setHeading(heading+fileModel.getName());
|
setHeading(heading+fileModel.getName());
|
||||||
}else
|
}else
|
||||||
setHeading(SmartConstants.HEADER_TITLE);
|
setHeading(SmartConstants.HEADER_TITLE);
|
||||||
|
@ -126,7 +121,7 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
|
||||||
txtName.setValue(fileModel.getName());
|
txtName.setValue(fileModel.getName());
|
||||||
txtName.setReadOnly(true);
|
txtName.setReadOnly(true);
|
||||||
txtName.setAutoValidate(true);
|
txtName.setAutoValidate(true);
|
||||||
|
|
||||||
if(SmartConstants.ITEM_NAME!=null)
|
if(SmartConstants.ITEM_NAME!=null)
|
||||||
txtName.setFieldLabel(SmartConstants.ITEM_NAME);
|
txtName.setFieldLabel(SmartConstants.ITEM_NAME);
|
||||||
|
|
||||||
|
@ -141,7 +136,7 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
|
||||||
Label labelShareWith = new Label("");
|
Label labelShareWith = new Label("");
|
||||||
if(SmartConstants.SHARE_WITH_USERS!=null)
|
if(SmartConstants.SHARE_WITH_USERS!=null)
|
||||||
labelShareWith.setText(SmartConstants.SHARE_WITH_USERS);
|
labelShareWith.setText(SmartConstants.SHARE_WITH_USERS);
|
||||||
|
|
||||||
flexTable.setWidget(0, 0, labelShareWith);
|
flexTable.setWidget(0, 0, labelShareWith);
|
||||||
flexTable.setWidget(0, 1, suggestPanel);
|
flexTable.setWidget(0, 1, suggestPanel);
|
||||||
|
|
||||||
|
@ -150,58 +145,54 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
|
||||||
Label labelAddMore = new Label("");
|
Label labelAddMore = new Label("");
|
||||||
if(SmartConstants.ADD_MORE!=null)
|
if(SmartConstants.ADD_MORE!=null)
|
||||||
labelAddMore.setText(SmartConstants.ADD_MORE);
|
labelAddMore.setText(SmartConstants.ADD_MORE);
|
||||||
|
|
||||||
flexTable.setWidget(1, 0, labelAddMore);
|
flexTable.setWidget(1, 0, labelAddMore);
|
||||||
flexTable.setWidget(1, 1, buttonMultiDrag);
|
flexTable.setWidget(1, 1, buttonMultiDrag);
|
||||||
|
|
||||||
|
|
||||||
if(listAlreadySharedContact!=null && listAlreadySharedContact.size()>0){
|
if(listAlreadySharedContact!=null && listAlreadySharedContact.size()>0){
|
||||||
|
|
||||||
userStore.getInfoContactModelsFromCredential(listAlreadySharedContact, new AsyncCallback<List<InfoContactModel>>() {
|
userStore.getInfoContactModelsFromCredential(listAlreadySharedContact, new AsyncCallback<List<InfoContactModel>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<InfoContactModel> result) {
|
public void onSuccess(List<InfoContactModel> result) {
|
||||||
for (InfoContactModel infoContactModel : result) {
|
for (InfoContactModel infoContactModel : result) {
|
||||||
if(infoContactModel.getName()!=null){
|
String name = infoContactModel.getName()!=null && !infoContactModel.getName().isEmpty()?infoContactModel.getName():infoContactModel.getLogin();
|
||||||
listAlreadyShared.add(infoContactModel);
|
listAlreadyShared.add(infoContactModel);
|
||||||
suggestPanel.addRecipient(infoContactModel.getName(),false);
|
suggestPanel.addRecipient(name,false);
|
||||||
layout();
|
layout();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
lc.unmask();
|
lc.unmask();
|
||||||
lc.layout();
|
lc.layout();
|
||||||
layout();
|
layout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
lc.unmask();
|
lc.unmask();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lc.add(flexTable);
|
lc.add(flexTable);
|
||||||
|
|
||||||
setFocusWidget(suggestPanel.getBox());
|
setFocusWidget(suggestPanel.getBox());
|
||||||
add(txtName);
|
add(txtName);
|
||||||
// add(txtOwner);
|
|
||||||
add(lc);
|
add(lc);
|
||||||
addListeners();
|
addListeners();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Gets the file to share.
|
||||||
* @return
|
*
|
||||||
|
* @return the file to share
|
||||||
*/
|
*/
|
||||||
public FileModel getFileToShare() {
|
public FileModel getFileToShare() {
|
||||||
return fileToShare;
|
return fileToShare;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inits the layout.
|
||||||
|
*/
|
||||||
private void initLayout(){
|
private void initLayout(){
|
||||||
FormLayout layout = new FormLayout();
|
FormLayout layout = new FormLayout();
|
||||||
layout.setLabelWidth(90);
|
layout.setLabelWidth(90);
|
||||||
|
@ -213,67 +204,78 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
|
||||||
setWidth(ConstantsSharing.WIDTH_DIALOG);
|
setWidth(ConstantsSharing.WIDTH_DIALOG);
|
||||||
setHeight(ConstantsSharing.HEIGHT_DIALOG);
|
setHeight(ConstantsSharing.HEIGHT_DIALOG);
|
||||||
setResizable(true);
|
setResizable(true);
|
||||||
setButtonAlign(HorizontalAlignment.CENTER);
|
setButtonAlign(HorizontalAlignment.CENTER);
|
||||||
setButtons(Dialog.OKCANCEL);
|
setButtons(Dialog.OKCANCEL);
|
||||||
setIcon(Resources.getIconShare());
|
setIcon(Resources.getIconShare());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Gets the shared list users.
|
||||||
|
*
|
||||||
* @return the selected contacts (as InfoContactModel)
|
* @return the selected contacts (as InfoContactModel)
|
||||||
*/
|
*/
|
||||||
public List<InfoContactModel> getSharedListUsers() {
|
public List<InfoContactModel> getSharedListUsers() {
|
||||||
// printSelectedUser();
|
// printSelectedUser();
|
||||||
|
|
||||||
List<InfoContactModel> contacts = new ArrayList<InfoContactModel>();
|
List<InfoContactModel> contacts = new ArrayList<InfoContactModel>();
|
||||||
|
|
||||||
for (InfoContactModel wsuser : suggestPanel.getSelectedUser()) {
|
for (InfoContactModel wsuser : suggestPanel.getSelectedUser()) {
|
||||||
CredentialModel credential = getCredentialModelFromInfoContactModel(wsuser);
|
CredentialModel credential = getCredentialModelFromInfoContactModel(wsuser);
|
||||||
wsuser.setReferenceCredential(credential);
|
wsuser.setReferenceCredential(credential);
|
||||||
contacts.add(wsuser);
|
contacts.add(wsuser);
|
||||||
}
|
}
|
||||||
|
|
||||||
return contacts;
|
return contacts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Gets the shared list users credential.
|
||||||
|
*
|
||||||
* @return the selected contacts (as CredentialModel)
|
* @return the selected contacts (as CredentialModel)
|
||||||
*/
|
*/
|
||||||
public List<CredentialModel> getSharedListUsersCredential() {
|
public List<CredentialModel> getSharedListUsersCredential() {
|
||||||
|
|
||||||
List<CredentialModel> toReturn = new ArrayList<CredentialModel>();
|
List<CredentialModel> toReturn = new ArrayList<CredentialModel>();
|
||||||
|
|
||||||
for (InfoContactModel wsuser : suggestPanel.getSelectedUser()) {
|
for (InfoContactModel wsuser : suggestPanel.getSelectedUser()) {
|
||||||
CredentialModel credential = wsuser.getReferenceCredential();
|
CredentialModel credential = wsuser.getReferenceCredential();
|
||||||
|
|
||||||
if(credential==null)
|
if(credential==null)
|
||||||
credential = new CredentialModel(null, "UNKWNOWN LOGIN", wsuser.isGroup());
|
credential = new CredentialModel(null, "UNKWNOWN LOGIN", wsuser.isGroup());
|
||||||
|
|
||||||
toReturn.add(credential);
|
toReturn.add(credential);
|
||||||
}
|
}
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the credential model from info contact model.
|
||||||
|
*
|
||||||
|
* @param infoContact the info contact
|
||||||
|
* @return the credential model from info contact model
|
||||||
|
*/
|
||||||
private CredentialModel getCredentialModelFromInfoContactModel(InfoContactModel infoContact){
|
private CredentialModel getCredentialModelFromInfoContactModel(InfoContactModel infoContact){
|
||||||
|
|
||||||
if(infoContact==null)
|
if(infoContact==null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if(infoContact.getReferenceCredential()==null){
|
if(infoContact.getReferenceCredential()==null){
|
||||||
return new CredentialModel(null, infoContact.getLogin(), infoContact.isGroup());
|
return new CredentialModel(null, infoContact.getLogin(), infoContact.isGroup());
|
||||||
}else if(infoContact.getReferenceCredential()!=null)
|
}else if(infoContact.getReferenceCredential()!=null)
|
||||||
return infoContact.getReferenceCredential();
|
return infoContact.getReferenceCredential();
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the listeners.
|
||||||
|
*/
|
||||||
public void addListeners(){
|
public void addListeners(){
|
||||||
|
|
||||||
this.getButtonById(Dialog.CANCEL).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
this.getButtonById(Dialog.CANCEL).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -281,8 +283,8 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
this.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
this.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -290,138 +292,172 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
|
||||||
if(isValidForm(false))
|
if(isValidForm(false))
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
buttonMultiDrag.addClickHandler(new ClickHandler() {
|
buttonMultiDrag.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
final DialogMultiDragContact dialog = new DialogMultiDragContact(true,true);
|
final DialogMultiDragContact dialog = new DialogMultiDragContact(true,true);
|
||||||
final MultiDragContact multiDrag = dialog.getMultiDrag();
|
final MultiDragContact multiDrag = dialog.getMultiDrag();
|
||||||
dialog.show();
|
dialog.show();
|
||||||
|
printSelectedUser();
|
||||||
List<InfoContactModel> exclusiveContacts = userStore.getExclusiveContactsFromAllContact(suggestPanel.getSelectedUser());
|
List<InfoContactModel> exclusiveContacts = userStore.getExclusiveContactsFromAllContact(suggestPanel.getSelectedUser());
|
||||||
multiDrag.addSourceContacts(exclusiveContacts);
|
multiDrag.addSourceContacts(exclusiveContacts);
|
||||||
|
|
||||||
|
|
||||||
for (InfoContactModel infoContactModel : suggestPanel.getSelectedUser()) {
|
for (InfoContactModel infoContactModel : suggestPanel.getSelectedUser()) {
|
||||||
if(!listAlreadyShared.contains(infoContactModel))
|
if(!listAlreadyShared.contains(infoContactModel))
|
||||||
multiDrag.addTargetContact(infoContactModel);
|
multiDrag.addTargetContact(infoContactModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
multiDrag.addAlreadySharedContacts(suggestPanel.getSelectedUser());
|
multiDrag.addAlreadySharedContacts(suggestPanel.getSelectedUser());
|
||||||
|
|
||||||
// multiDrag.addTargetContacts(suggestPanel.getSelectedUser());
|
|
||||||
|
|
||||||
dialog.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
dialog.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void componentSelected(ButtonEvent ce) {
|
public void componentSelected(ButtonEvent ce) {
|
||||||
|
|
||||||
initSuggestContacts();
|
initSuggestContacts();
|
||||||
|
|
||||||
for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
|
for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
|
||||||
suggestPanel.addRecipient(infoContactModel.getName(),true);
|
suggestPanel.addRecipient(infoContactModel.getName(),true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
|
// for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
|
||||||
//
|
//
|
||||||
// if(!listAlreadySharedContains(infoContactModel))
|
// if(!listAlreadySharedContains(infoContactModel))
|
||||||
// suggestPanel.addRecipient(infoContactModel.getName(),true);
|
// suggestPanel.addRecipient(infoContactModel.getName(),true);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
suggestPanel.boxSetFocus();
|
suggestPanel.boxSetFocus();
|
||||||
|
|
||||||
// printSelectedUser();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List already shared contains.
|
||||||
|
*
|
||||||
|
* @param contact the contact
|
||||||
|
* @return true, if successful
|
||||||
|
*/
|
||||||
private boolean listAlreadySharedContains(InfoContactModel contact){
|
private boolean listAlreadySharedContains(InfoContactModel contact){
|
||||||
|
|
||||||
if(contact==null)
|
if(contact==null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (InfoContactModel ct : listAlreadyShared) {
|
for (InfoContactModel ct : listAlreadyShared) {
|
||||||
|
|
||||||
if(ct.getLogin().compareTo(contact.getLogin())==0){
|
if(ct.getLogin().compareTo(contact.getLogin())==0){
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//DEBUG
|
//DEBUG
|
||||||
|
/**
|
||||||
|
* Prints the selected user.
|
||||||
|
*/
|
||||||
private void printSelectedUser(){
|
private void printSelectedUser(){
|
||||||
|
|
||||||
System.out.println("SELETECTED USERS: ");
|
GWT.log("SELETECTED USERS: ");
|
||||||
for (InfoContactModel contact : suggestPanel.getSelectedUser())
|
for (InfoContactModel contact : suggestPanel.getSelectedUser())
|
||||||
System.out.println(contact);
|
GWT.log(contact.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inits the suggest contacts.
|
||||||
|
*/
|
||||||
private void initSuggestContacts(){
|
private void initSuggestContacts(){
|
||||||
|
|
||||||
suggestPanel.resetItemSelected();
|
suggestPanel.resetItemSelected();
|
||||||
|
|
||||||
for (InfoContactModel contact : listAlreadyShared) {
|
for (InfoContactModel contact : listAlreadyShared) {
|
||||||
suggestPanel.addRecipient(contact.getName(), false);
|
suggestPanel.addRecipient(contact.getName(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the as error.
|
||||||
|
*
|
||||||
|
* @param message the new as error
|
||||||
|
*/
|
||||||
public void setAsError(String message){
|
public void setAsError(String message){
|
||||||
enableFormDialog(false);
|
enableFormDialog(false);
|
||||||
this.add(new Html("<br/> <p style=\"color:red; font-family:verdana, arial; font-size:14px;\">"+message+"</p>"));
|
this.add(new Html("<br/> <p style=\"color:red; font-family:verdana, arial; font-size:14px;\">"+message+"</p>"));
|
||||||
this.layout();
|
this.layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable form dialog.
|
||||||
|
*
|
||||||
|
* @param bool the bool
|
||||||
|
*/
|
||||||
private void enableFormDialog(boolean bool){
|
private void enableFormDialog(boolean bool){
|
||||||
getButtonById(Dialog.OK).setEnabled(bool);
|
getButtonById(Dialog.OK).setEnabled(bool);
|
||||||
buttonMultiDrag.setEnabled(bool);
|
buttonMultiDrag.setEnabled(bool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the name.
|
||||||
|
*
|
||||||
|
* @return the name
|
||||||
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return txtName.getValue();
|
return txtName.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Checks if is valid form.
|
||||||
|
*
|
||||||
* @param displayAlert in case of error
|
* @param displayAlert in case of error
|
||||||
* @return
|
* @return true, if is valid form
|
||||||
*/
|
*/
|
||||||
public boolean isValidForm(boolean displayAlert){
|
public boolean isValidForm(boolean displayAlert){
|
||||||
|
|
||||||
if(!txtName.isValid()){
|
if(!txtName.isValid()){
|
||||||
if(displayAlert)
|
if(displayAlert)
|
||||||
MessageBox.alert("Attention", "Name must not be empty", null);
|
MessageBox.alert("Attention", "Name must not be empty", null);
|
||||||
txtName.focus();
|
txtName.focus();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getSharedListUsers().size()==0){
|
if(getSharedListUsers().size()==0){
|
||||||
if(displayAlert)
|
if(displayAlert)
|
||||||
MessageBox.alert("Attention", SmartConstants.ERROR_NO_USER_SELECTED, null);
|
MessageBox.alert("Attention", SmartConstants.ERROR_NO_USER_SELECTED, null);
|
||||||
suggestPanel.boxSetFocus();
|
suggestPanel.boxSetFocus();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is read groups from hl.
|
||||||
|
*
|
||||||
|
* @return true, if is read groups from hl
|
||||||
|
*/
|
||||||
public boolean isReadGroupsFromHL() {
|
public boolean isReadGroupsFromHL() {
|
||||||
return readGroupsFromHL;
|
return readGroupsFromHL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is read groups from portal.
|
||||||
|
*
|
||||||
|
* @return true, if is read groups from portal
|
||||||
|
*/
|
||||||
public boolean isReadGroupsFromPortal() {
|
public boolean isReadGroupsFromPortal() {
|
||||||
return readGroupsFromPortal;
|
return readGroupsFromPortal;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,10 +25,10 @@ import com.google.gwt.user.client.ui.SuggestOracle;
|
||||||
import com.google.gwt.user.client.ui.TextBox;
|
import com.google.gwt.user.client.ui.TextBox;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* The Class MultiValuePanel.
|
||||||
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
* @Feb 25, 2014
|
* @Feb 25, 2014
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class MultiValuePanel extends Composite {
|
public class MultiValuePanel extends Composite {
|
||||||
|
|
||||||
|
@ -36,24 +36,27 @@ public class MultiValuePanel extends Composite {
|
||||||
private List<String> itemsSelected = new ArrayList<String>();
|
private List<String> itemsSelected = new ArrayList<String>();
|
||||||
FlowPanel panel = new FlowPanel();
|
FlowPanel panel = new FlowPanel();
|
||||||
// private HandlerManager eventBus;
|
// private HandlerManager eventBus;
|
||||||
private HashMap<String, InfoContactModel> users = new HashMap<String, InfoContactModel>();
|
private HashMap<String, InfoContactModel> users = new HashMap<String, InfoContactModel>(); //AN HAST FULLNAME - INFOCONTACTMODEL
|
||||||
private BulletList listBullet = new BulletList();
|
private BulletList listBullet = new BulletList();
|
||||||
private SuggestBox box;
|
private SuggestBox box;
|
||||||
private ContactFetcher userFetch;
|
private ContactFetcher userFetch;
|
||||||
private MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
|
private MultiWordSuggestOracle oracle = new MultiWordSuggestOracle(); //ORACLE OF FULL NAMES
|
||||||
private boolean readGroupsFromHL;
|
private boolean readGroupsFromHL;
|
||||||
private boolean readGroupsFromPortal;
|
private boolean readGroupsFromPortal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Instantiates a new multi value panel.
|
||||||
* @param userFetch the ContactFetcher
|
*
|
||||||
|
* @param userFetch the ContactFetcher
|
||||||
|
* @param readGroupsFromHL the read groups from hl
|
||||||
|
* @param readGroupsFromPortal the read groups from portal
|
||||||
*/
|
*/
|
||||||
public MultiValuePanel(ContactFetcher userFetch, boolean readGroupsFromHL, boolean readGroupsFromPortal) {
|
public MultiValuePanel(ContactFetcher userFetch, boolean readGroupsFromHL, boolean readGroupsFromPortal) {
|
||||||
this.userFetch = userFetch;
|
this.userFetch = userFetch;
|
||||||
this.readGroupsFromHL = readGroupsFromHL;
|
this.readGroupsFromHL = readGroupsFromHL;
|
||||||
this.readGroupsFromPortal = readGroupsFromPortal;
|
this.readGroupsFromPortal = readGroupsFromPortal;
|
||||||
initWidget(panel);
|
initWidget(panel);
|
||||||
panel.setWidth("100%");
|
panel.setWidth("100%");
|
||||||
listBullet.setStyleName("multivalue-panel-suggest");
|
listBullet.setStyleName("multivalue-panel-suggest");
|
||||||
final ListItem item = new ListItem();
|
final ListItem item = new ListItem();
|
||||||
final TextBox itemBox = new TextBox();
|
final TextBox itemBox = new TextBox();
|
||||||
|
@ -69,22 +72,22 @@ public class MultiValuePanel extends Composite {
|
||||||
// handle backspace
|
// handle backspace
|
||||||
if (event.getNativeKeyCode() == KeyCodes.KEY_BACKSPACE) {
|
if (event.getNativeKeyCode() == KeyCodes.KEY_BACKSPACE) {
|
||||||
if ("".equals(itemBox.getValue().trim())) {
|
if ("".equals(itemBox.getValue().trim())) {
|
||||||
|
|
||||||
if(listBullet.getWidgetCount()>2){
|
if(listBullet.getWidgetCount()>2){
|
||||||
ListItem li = (ListItem) listBullet.getWidget(listBullet.getWidgetCount() - 2);
|
ListItem li = (ListItem) listBullet.getWidget(listBullet.getWidgetCount() - 2);
|
||||||
|
|
||||||
if(li.getWidget(0) instanceof Paragraph){
|
if(li.getWidget(0) instanceof Paragraph){
|
||||||
Paragraph p = (Paragraph) li.getWidget(0);
|
Paragraph p = (Paragraph) li.getWidget(0);
|
||||||
GWT.log("p "+p.getText() +" is removable : " + p.isRemovable());
|
GWT.log("p "+p.getText() +" is removable : " + p.isRemovable());
|
||||||
if (itemsSelected.contains(p.getText()) && (p.isRemovable()==true)) {
|
if (itemsSelected.contains(p.getText()) && p.isRemovable()==true) {
|
||||||
itemsSelected.remove(p.getText());
|
itemsSelected.remove(p.getText());
|
||||||
GWT.log("Removing selected item: " + p.getText() + "'");
|
GWT.log("Removing selected item: " + p.getText() + "'");
|
||||||
listBullet.remove(li);
|
listBullet.remove(li);
|
||||||
}
|
}
|
||||||
|
|
||||||
itemBox.setFocus(true);
|
itemBox.setFocus(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,22 +102,30 @@ public class MultiValuePanel extends Composite {
|
||||||
panel.add(listBullet);
|
panel.add(listBullet);
|
||||||
box.getElement().setId("suggestion_box"); //needed for the focus on click
|
box.getElement().setId("suggestion_box"); //needed for the focus on click
|
||||||
panel.getElement().setAttribute("onclick", "document.getElementById('suggestion_box').focus()");
|
panel.getElement().setAttribute("onclick", "document.getElementById('suggestion_box').focus()");
|
||||||
// box.setFocus(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Box set focus.
|
||||||
|
*/
|
||||||
public void boxSetFocus(){
|
public void boxSetFocus(){
|
||||||
box.getElement().focus();
|
box.getElement().focus();
|
||||||
box.setFocus(true);
|
box.setFocus(true);
|
||||||
// panel.getElement().setAttribute("onclick", "document.getElementById('suggestion_box').focus()");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the flow panel.
|
||||||
|
*
|
||||||
|
* @return the flow panel
|
||||||
|
*/
|
||||||
public FlowPanel getFlowPanel(){
|
public FlowPanel getFlowPanel(){
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* actually insert the contact in the flow panel
|
* actually insert the contact in the flow panel.
|
||||||
* @param itemBox
|
*
|
||||||
* @param list
|
* @param itemBox the item box
|
||||||
|
* @param list the list
|
||||||
*/
|
*/
|
||||||
private void chosenContactItem(final TextBox itemBox, final BulletList list) {
|
private void chosenContactItem(final TextBox itemBox, final BulletList list) {
|
||||||
if (itemBox.getValue() != null && !"".equals(itemBox.getValue().trim())) {
|
if (itemBox.getValue() != null && !"".equals(itemBox.getValue().trim())) {
|
||||||
|
@ -142,25 +153,34 @@ public class MultiValuePanel extends Composite {
|
||||||
itemBox.setFocus(true);
|
itemBox.setFocus(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Gets the selected user.
|
||||||
|
*
|
||||||
* @return the selected contacts (user logins e.g. pino.pini)
|
* @return the selected contacts (user logins e.g. pino.pini)
|
||||||
*/
|
*/
|
||||||
public List<InfoContactModel> getSelectedUser() {
|
public List<InfoContactModel> getSelectedUser() {
|
||||||
if (users == null)
|
if (users == null)
|
||||||
return new ArrayList<InfoContactModel>();
|
return new ArrayList<InfoContactModel>();
|
||||||
else {
|
else {
|
||||||
List<InfoContactModel> toReturn = new ArrayList<InfoContactModel>();
|
List<InfoContactModel> toReturn = new ArrayList<InfoContactModel>();
|
||||||
|
// GWT.log("Selected User: "+itemsSelected);
|
||||||
for (String login : itemsSelected) {
|
// GWT.log("users: "+users);
|
||||||
InfoContactModel wsuser = users.get(login);
|
for (String fullName : itemsSelected) {
|
||||||
|
InfoContactModel wsuser = users.get(fullName);
|
||||||
if(wsuser!= null && !toReturn.contains(wsuser))
|
if(wsuser!= null && !toReturn.contains(wsuser))
|
||||||
toReturn.add(wsuser);
|
toReturn.add(wsuser);
|
||||||
}
|
}
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the list item.
|
||||||
|
*
|
||||||
|
* @param displayItem the display item
|
||||||
|
* @param list the list
|
||||||
|
*/
|
||||||
private void removeListItem(ListItem displayItem, BulletList list) {
|
private void removeListItem(ListItem displayItem, BulletList list) {
|
||||||
GWT.log("Removing: " + displayItem.getWidget(0).getElement().getInnerHTML(), null);
|
GWT.log("Removing: " + displayItem.getWidget(0).getElement().getInnerHTML(), null);
|
||||||
itemsSelected.remove(displayItem.getWidget(0).getElement().getInnerHTML());
|
itemsSelected.remove(displayItem.getWidget(0).getElement().getInnerHTML());
|
||||||
|
@ -168,31 +188,34 @@ public class MultiValuePanel extends Composite {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Gets the suggestions.
|
||||||
*
|
*
|
||||||
* @return names of possible contacts
|
* @return names of possible contacts
|
||||||
*/
|
*/
|
||||||
private MultiWordSuggestOracle getSuggestions() {
|
private MultiWordSuggestOracle getSuggestions() {
|
||||||
|
|
||||||
userFetch.getListContact(contacts, false,readGroupsFromHL,readGroupsFromPortal);
|
userFetch.getListContact(contacts, false,readGroupsFromHL,readGroupsFromPortal);
|
||||||
|
|
||||||
return oracle;
|
return oracle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update suggestions.
|
||||||
|
*
|
||||||
|
* @param result the result
|
||||||
|
*/
|
||||||
public void updateSuggestions(List<InfoContactModel> result) {
|
public void updateSuggestions(List<InfoContactModel> result) {
|
||||||
|
|
||||||
oracle.clear();
|
oracle.clear();
|
||||||
|
|
||||||
for (InfoContactModel wsUser : result) {
|
for (InfoContactModel wsUser : result) {
|
||||||
oracle.add(wsUser.getName());
|
oracle.add(wsUser.getName());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private AsyncCallback<List<InfoContactModel>> contacts = new AsyncCallback<List<InfoContactModel>>() {
|
|
||||||
|
|
||||||
|
|
||||||
|
private AsyncCallback<List<InfoContactModel>> contacts = new AsyncCallback<List<InfoContactModel>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
GWT.log("Error on loading contacts");
|
GWT.log("Error on loading contacts");
|
||||||
|
@ -201,43 +224,51 @@ public class MultiValuePanel extends Composite {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<InfoContactModel> result) {
|
public void onSuccess(List<InfoContactModel> result) {
|
||||||
|
|
||||||
users.clear();
|
users.clear();
|
||||||
|
|
||||||
for (InfoContactModel wsUser : result) {
|
for (InfoContactModel wsUser : result) {
|
||||||
oracle.add(wsUser.getName());
|
String fullName = wsUser.getName();
|
||||||
users.put(wsUser.getName(), wsUser);
|
if(users.containsKey(fullName)){ //case of homonimy
|
||||||
}
|
fullName = fullName+"_";
|
||||||
}
|
users.put(fullName, wsUser);
|
||||||
};
|
}else
|
||||||
|
users.put(fullName, wsUser);
|
||||||
|
|
||||||
|
oracle.add(fullName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset item selected.
|
||||||
|
*/
|
||||||
public void resetItemSelected(){
|
public void resetItemSelected(){
|
||||||
|
|
||||||
listBullet.clear();
|
listBullet.clear();
|
||||||
itemsSelected.clear();
|
itemsSelected.clear();
|
||||||
ListItem item = new ListItem();
|
ListItem item = new ListItem();
|
||||||
item.add(box);
|
item.add(box);
|
||||||
listBullet.add(item);
|
listBullet.add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Adds the recipient.
|
||||||
* @param contact
|
*
|
||||||
* @param displayRemoveItem
|
* @param fullName the full name
|
||||||
|
* @param displayRemoveItem the display remove item
|
||||||
*/
|
*/
|
||||||
public void addRecipient(String fullName, boolean displayRemoveItem) {
|
public void addRecipient(String fullName, boolean displayRemoveItem) {
|
||||||
|
|
||||||
if (fullName != null) {
|
if (fullName != null) {
|
||||||
|
|
||||||
TextBox itemBox = new TextBox();
|
TextBox itemBox = new TextBox();
|
||||||
itemBox.setText(fullName);
|
itemBox.setText(fullName);
|
||||||
itemBox.setValue(fullName);
|
itemBox.setValue(fullName);
|
||||||
final ListItem displayItem = new ListItem();
|
final ListItem displayItem = new ListItem();
|
||||||
|
|
||||||
Paragraph p = new Paragraph(fullName);
|
Paragraph p = new Paragraph(fullName);
|
||||||
displayItem.add(p);
|
displayItem.add(p);
|
||||||
|
|
||||||
if(displayRemoveItem){
|
if(displayRemoveItem){
|
||||||
displayItem.setStyleName("multivalue-panel-token-ws");
|
displayItem.setStyleName("multivalue-panel-token-ws");
|
||||||
p.setRemovable(true);
|
p.setRemovable(true);
|
||||||
|
@ -247,15 +278,13 @@ public class MultiValuePanel extends Composite {
|
||||||
removeListItem(displayItem, listBullet);
|
removeListItem(displayItem, listBullet);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
displayItem.add(span);
|
displayItem.add(span);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
displayItem.setStyleName("multivalue-panel-token-ws-notselectable");
|
displayItem.setStyleName("multivalue-panel-token-ws-notselectable");
|
||||||
p.setRemovable(false);
|
p.setRemovable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GWT.log("Adding selected wp item '" + itemBox.getValue());
|
GWT.log("Adding selected wp item '" + itemBox.getValue());
|
||||||
itemsSelected.add(itemBox.getValue());
|
itemsSelected.add(itemBox.getValue());
|
||||||
|
@ -265,15 +294,23 @@ public class MultiValuePanel extends Composite {
|
||||||
itemBox.setValue("");
|
itemBox.setValue("");
|
||||||
itemBox.setFocus(true);
|
itemBox.setFocus(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear list.
|
||||||
|
*/
|
||||||
public void clearList() {
|
public void clearList() {
|
||||||
listBullet.clear();
|
listBullet.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the box.
|
||||||
|
*
|
||||||
|
* @return the box
|
||||||
|
*/
|
||||||
public SuggestBox getBox() {
|
public SuggestBox getBox() {
|
||||||
return box;
|
return box;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.widgets.workspacesharingwidget.server;
|
package org.gcube.portlets.widgets.workspacesharingwidget.server;
|
||||||
|
|
||||||
|
@ -35,9 +35,10 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The Class GWTWorkspaceSharingBuilder.
|
||||||
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
* @Feb 25, 2014
|
* @Feb 25, 2014
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class GWTWorkspaceSharingBuilder {
|
public class GWTWorkspaceSharingBuilder {
|
||||||
|
|
||||||
|
@ -48,9 +49,9 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
protected static HashMap<String, InfoContactModel> hashTestUser = null;
|
protected static HashMap<String, InfoContactModel> hashTestUser = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used in test mode
|
* Used in test mode.
|
||||||
*
|
*
|
||||||
* @return
|
* @return the hash test users
|
||||||
*/
|
*/
|
||||||
public static HashMap<String, InfoContactModel> getHashTestUsers() {
|
public static HashMap<String, InfoContactModel> getHashTestUsers() {
|
||||||
|
|
||||||
|
@ -87,7 +88,7 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
hashTestUser.put("valentina.marioli", new InfoContactModel(
|
hashTestUser.put("valentina.marioli", new InfoContactModel(
|
||||||
"valentina.marioli", "valentina.marioli",
|
"valentina.marioli", "valentina.marioli",
|
||||||
"Valentina Marioli", false));
|
"Valentina Marioli", false));
|
||||||
|
|
||||||
hashTestUser.put("devVRE", new InfoContactModel(
|
hashTestUser.put("devVRE", new InfoContactModel(
|
||||||
"devVRE", "devVRE",
|
"devVRE", "devVRE",
|
||||||
"devVRE", true));
|
"devVRE", true));
|
||||||
|
@ -103,17 +104,20 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param infoContactModel
|
* Sets the user logged.
|
||||||
|
*
|
||||||
|
* @param infoContactModel the new user logged
|
||||||
*/
|
*/
|
||||||
public void setUserLogged(InfoContactModel infoContactModel) {
|
public void setUserLogged(InfoContactModel infoContactModel) {
|
||||||
this.userLogged = infoContactModel;
|
this.userLogged = infoContactModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Builds the gxt list contacts model from gcube group.
|
||||||
* @param list
|
*
|
||||||
* @return
|
* @param list the list
|
||||||
* @throws InternalErrorException
|
* @return the list
|
||||||
|
* @throws InternalErrorException the internal error exception
|
||||||
*/
|
*/
|
||||||
public List<InfoContactModel> buildGXTListContactsModelFromGcubeGroup(List<GCubeGroup> list) throws InternalErrorException {
|
public List<InfoContactModel> buildGXTListContactsModelFromGcubeGroup(List<GCubeGroup> list) throws InternalErrorException {
|
||||||
|
|
||||||
|
@ -159,13 +163,14 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
|
|
||||||
return listContactsModel;
|
return listContactsModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Builds the gxt list contacts model from v os.
|
||||||
* @param voPath
|
*
|
||||||
* @param list
|
* @param listVO the list vo
|
||||||
* @return
|
* @param voPath the vo path
|
||||||
* @throws InternalErrorException
|
* @return the list
|
||||||
|
* @throws InternalErrorException the internal error exception
|
||||||
*/
|
*/
|
||||||
public List<InfoContactModel> buildGXTListContactsModelFromVOs(List<VO> listVO, String voPath) throws InternalErrorException {
|
public List<InfoContactModel> buildGXTListContactsModelFromVOs(List<VO> listVO, String voPath) throws InternalErrorException {
|
||||||
|
|
||||||
|
@ -174,11 +179,11 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
if(voPath==null){
|
if(voPath==null){
|
||||||
voPath=ConstantsSharing.PATH_SEPARATOR;
|
voPath=ConstantsSharing.PATH_SEPARATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(voPath!=null && !voPath.endsWith(ConstantsSharing.PATH_SEPARATOR)){
|
if(voPath!=null && !voPath.endsWith(ConstantsSharing.PATH_SEPARATOR)){
|
||||||
voPath+=ConstantsSharing.PATH_SEPARATOR;
|
voPath+=ConstantsSharing.PATH_SEPARATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listVO == null){
|
if (listVO == null){
|
||||||
logger.warn("List<VO> is null, returning");
|
logger.warn("List<VO> is null, returning");
|
||||||
return listContactsModel;
|
return listContactsModel;
|
||||||
|
@ -190,20 +195,21 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
|
|
||||||
for (VO vo : listVO) {
|
for (VO vo : listVO) {
|
||||||
List<VRE> vres = vo.getVres();
|
List<VRE> vres = vo.getVres();
|
||||||
|
|
||||||
logger.trace("vo getGroupName: "+ vo.getGroupName());
|
logger.trace("vo getGroupName: "+ vo.getGroupName());
|
||||||
logger.trace("vo getName: "+ vo.getName());
|
logger.trace("vo getName: "+ vo.getName());
|
||||||
logger.trace("Building list contact model...");
|
logger.trace("Building list contact model...");
|
||||||
|
|
||||||
if(vres!=null){
|
if(vres!=null){
|
||||||
logger.trace("vres from VO "+vo.getName() +" having size :" +vres.size() +", converting");
|
logger.trace("vres from VO "+vo.getName() +" having size :" +vres.size() +", converting");
|
||||||
for (VRE vre : vres) {
|
for (VRE vre : vres) {
|
||||||
|
|
||||||
if(vre.getName()!=null || !vre.getName().isEmpty()){
|
if(vre.getName()!=null || !vre.getName().isEmpty()){
|
||||||
String groupId = voPath+vre.getName();
|
String groupId = voPath+vre.getName();
|
||||||
InfoContactModel contact = new InfoContactModel(groupId, groupId, vre.getName(), true);
|
logger.trace("adding contact groupId: "+groupId +" VRE name: "+vre.getName());
|
||||||
logger.trace("Adding group contact " + contact);
|
// InfoContactModel contact = new InfoContactModel(groupId, groupId, vre.getName(), true);
|
||||||
listContactsModel.add(contact);
|
// logger.trace("Adding group contact " + contact);
|
||||||
|
// listContactsModel.add(contact);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
|
@ -216,6 +222,13 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
return listContactsModel;
|
return listContactsModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds the gxt list contacts model from user model.
|
||||||
|
*
|
||||||
|
* @param listUsers the list users
|
||||||
|
* @return the list
|
||||||
|
* @throws InternalErrorException the internal error exception
|
||||||
|
*/
|
||||||
public List<InfoContactModel> buildGXTListContactsModelFromUserModel(
|
public List<InfoContactModel> buildGXTListContactsModelFromUserModel(
|
||||||
List<UserModel> listUsers) throws InternalErrorException {
|
List<UserModel> listUsers) throws InternalErrorException {
|
||||||
|
|
||||||
|
@ -247,9 +260,10 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Builds the gxt info contacts from portal logins.
|
||||||
* @param listPortalLogin
|
*
|
||||||
* @return
|
* @param listPortalLogin the list portal login
|
||||||
|
* @return the list
|
||||||
*/
|
*/
|
||||||
public List<InfoContactModel> buildGxtInfoContactsFromPortalLogins(List<String> listPortalLogin) {
|
public List<InfoContactModel> buildGxtInfoContactsFromPortalLogins(List<String> listPortalLogin) {
|
||||||
|
|
||||||
|
@ -261,27 +275,53 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Builds the gxt info contact from portal login.
|
||||||
* @param portalLogin
|
*
|
||||||
* @return
|
* @param portalLogin the portal login
|
||||||
|
* @return the info contact model
|
||||||
*/
|
*/
|
||||||
protected InfoContactModel buildGxtInfoContactFromPortalLogin(String portalLogin) {
|
protected InfoContactModel buildGxtInfoContactFromPortalLogin(String portalLogin) {
|
||||||
|
|
||||||
if (portalLogin == null) {
|
if (portalLogin == null) {
|
||||||
logger.warn("portal login is null, return empty");
|
logger.warn("Contact login is null, return empty");
|
||||||
portalLogin = "";
|
portalLogin = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO ISGROUP
|
|
||||||
return new InfoContactModel(portalLogin, portalLogin,UserUtil.getUserFullName(portalLogin), false);
|
return new InfoContactModel(portalLogin, portalLogin,UserUtil.getUserFullName(portalLogin), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds the gxt info contact from portal group.
|
||||||
|
*
|
||||||
|
* @param grouoLogin the grouo login
|
||||||
|
* @return the info contact model
|
||||||
|
*/
|
||||||
|
protected InfoContactModel buildGxtInfoContactFromPortalGroup(String grouoLogin) {
|
||||||
|
|
||||||
|
String groupName = "";
|
||||||
|
if (grouoLogin == null) {
|
||||||
|
logger.warn("GroupLogin is null, return empty");
|
||||||
|
grouoLogin = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
//RECOVERING VRE NAME
|
||||||
|
if(grouoLogin.contains("/")){
|
||||||
|
int start = grouoLogin.lastIndexOf("/");
|
||||||
|
int end = grouoLogin.length();
|
||||||
|
if(start<end)
|
||||||
|
groupName = grouoLogin.substring(start+1, end);
|
||||||
|
else
|
||||||
|
groupName = grouoLogin;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new InfoContactModel(grouoLogin, grouoLogin, groupName , true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used in test mode
|
* Used in test mode.
|
||||||
*
|
*
|
||||||
* @param listPortalLogin
|
* @param listPortalLogin the list portal login
|
||||||
* @return
|
* @return the list
|
||||||
*/
|
*/
|
||||||
protected List<InfoContactModel> buildGxtInfoContactFromPortalLoginTestMode(List<String> listPortalLogin) {
|
protected List<InfoContactModel> buildGxtInfoContactFromPortalLoginTestMode(List<String> listPortalLogin) {
|
||||||
|
|
||||||
|
@ -295,10 +335,11 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Builds the gxt info contact model.
|
||||||
* @param user
|
*
|
||||||
* @return
|
* @param user the user
|
||||||
* @throws InternalErrorException
|
* @return the info contact model
|
||||||
|
* @throws InternalErrorException the internal error exception
|
||||||
*/
|
*/
|
||||||
public InfoContactModel buildGXTInfoContactModel(User user)
|
public InfoContactModel buildGXTInfoContactModel(User user)
|
||||||
throws InternalErrorException {
|
throws InternalErrorException {
|
||||||
|
@ -311,6 +352,14 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
return new InfoContactModel();
|
return new InfoContactModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds the gxt file model item.
|
||||||
|
*
|
||||||
|
* @param item the item
|
||||||
|
* @param parentFolderModel the parent folder model
|
||||||
|
* @return the file model
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
protected FileModel buildGXTFileModelItem(WorkspaceItem item,
|
protected FileModel buildGXTFileModelItem(WorkspaceItem item,
|
||||||
FileModel parentFolderModel) throws Exception {
|
FileModel parentFolderModel) throws Exception {
|
||||||
FileModel fileModel = null;
|
FileModel fileModel = null;
|
||||||
|
@ -366,6 +415,13 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the folder item type.
|
||||||
|
*
|
||||||
|
* @param fileModel the file model
|
||||||
|
* @param worspaceFolderItem the worspace folder item
|
||||||
|
* @return the file model
|
||||||
|
*/
|
||||||
protected FileModel setFolderItemType(FileModel fileModel,
|
protected FileModel setFolderItemType(FileModel fileModel,
|
||||||
FolderItem worspaceFolderItem) {
|
FolderItem worspaceFolderItem) {
|
||||||
|
|
||||||
|
@ -439,6 +495,13 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
return fileModel;
|
return fileModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the workspace acl from ac ls.
|
||||||
|
*
|
||||||
|
* @param types the types
|
||||||
|
* @return the workspace acl from ac ls
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
public List<WorkspaceACL> getWorkspaceACLFromACLs(List<ACLType> types) throws Exception {
|
public List<WorkspaceACL> getWorkspaceACLFromACLs(List<ACLType> types) throws Exception {
|
||||||
|
|
||||||
List<WorkspaceACL> acls = new ArrayList<WorkspaceACL>();
|
List<WorkspaceACL> acls = new ArrayList<WorkspaceACL>();
|
||||||
|
@ -481,20 +544,22 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
|
|
||||||
return acls;
|
return acls;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param aclOwner
|
* Gets the formatted html acl from ac ls.
|
||||||
* @return
|
*
|
||||||
|
* @param aclOwner the acl owner
|
||||||
|
* @return the formatted html acl from ac ls
|
||||||
*/
|
*/
|
||||||
public String getFormattedHtmlACLFromACLs(Map<ACLType, List<String>> aclOwner) {
|
public String getFormattedHtmlACLFromACLs(Map<ACLType, List<String>> aclOwner) {
|
||||||
|
|
||||||
String html = "<div style=\"width: 100%; text-align:left; font-size: 10px;\">";
|
String html = "<div style=\"width: 100%; text-align:left; font-size: 10px;\">";
|
||||||
|
|
||||||
logger.trace("Formatting "+aclOwner.size() +" ACL/s");
|
logger.trace("Formatting "+aclOwner.size() +" ACL/s");
|
||||||
|
|
||||||
for (ACLType type : aclOwner.keySet()) {
|
for (ACLType type : aclOwner.keySet()) {
|
||||||
List<String> listLogins = aclOwner.get(type);
|
List<String> listLogins = aclOwner.get(type);
|
||||||
|
|
||||||
html+="<span style=\"font-weight:bold; padding-top: 5px;\">"+type+": </span>";
|
html+="<span style=\"font-weight:bold; padding-top: 5px;\">"+type+": </span>";
|
||||||
html+="<span style=\"font-weight:normal;\">";
|
html+="<span style=\"font-weight:normal;\">";
|
||||||
for (String login : listLogins) {
|
for (String login : listLogins) {
|
||||||
|
@ -508,8 +573,8 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
html+="</span><br/>";
|
html+="</span><br/>";
|
||||||
}
|
}
|
||||||
html+="</div>";
|
html+="</div>";
|
||||||
|
|
||||||
|
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,8 +51,8 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
WorkspaceSharingService {
|
WorkspaceSharingService {
|
||||||
|
|
||||||
protected static Logger logger = LoggerFactory.getLogger(WorkspaceSharingServiceImpl.class);
|
protected static Logger logger = LoggerFactory.getLogger(WorkspaceSharingServiceImpl.class);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the GWT workspace builder.
|
* Gets the GWT workspace builder.
|
||||||
*
|
*
|
||||||
|
@ -75,27 +75,27 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
{
|
{
|
||||||
return WsUtil.getWorkspace(this.getThreadLocalRequest().getSession());
|
return WsUtil.getWorkspace(this.getThreadLocalRequest().getSession());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the notification producer.
|
* Gets the notification producer.
|
||||||
*
|
*
|
||||||
* @return the notification producer
|
* @return the notification producer
|
||||||
*/
|
*/
|
||||||
protected NotificationsProducer getNotificationProducer(){
|
protected NotificationsProducer getNotificationProducer(){
|
||||||
|
|
||||||
return WsUtil.getNotificationProducer(WsUtil.getAslSession(this.getThreadLocalRequest().getSession()));
|
return WsUtil.getNotificationProducer(WsUtil.getAslSession(this.getThreadLocalRequest().getSession()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the scope util filter.
|
* Gets the scope util filter.
|
||||||
*
|
*
|
||||||
* @return the scope util filter
|
* @return the scope util filter
|
||||||
*/
|
*/
|
||||||
protected ScopeUtility getScopeUtilFilter(){
|
protected ScopeUtility getScopeUtilFilter(){
|
||||||
|
|
||||||
return WsUtil.getScopeUtilFilter(this.getThreadLocalRequest().getSession());
|
return WsUtil.getScopeUtilFilter(this.getThreadLocalRequest().getSession());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if is test mode.
|
* Checks if is test mode.
|
||||||
*
|
*
|
||||||
|
@ -104,19 +104,19 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
protected boolean isTestMode(){
|
protected boolean isTestMode(){
|
||||||
return !WsUtil.isWithinPortal(); //IS NOT INTO PORTAL
|
return !WsUtil.isWithinPortal(); //IS NOT INTO PORTAL
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingService#getAllContacts(boolean, boolean)
|
* @see org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingService#getAllContacts(boolean, boolean)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<InfoContactModel> getAllContacts(boolean readGroupsFromHL, boolean readGroupsFromPortal) throws Exception {
|
public List<InfoContactModel> getAllContacts(boolean readGroupsFromHL, boolean readGroupsFromPortal) throws Exception {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ASLSession aslSession = WsUtil.getAslSession(this.getThreadLocalRequest().getSession()); //THIS FORCE THE SESSION CREATION
|
ASLSession aslSession = WsUtil.getAslSession(this.getThreadLocalRequest().getSession()); //THIS FORCE THE SESSION CREATION
|
||||||
logger.info("Get all contacts");
|
logger.info("Get all contacts");
|
||||||
|
|
||||||
GWTWorkspaceSharingBuilder builder = getGWTWorkspaceBuilder();
|
GWTWorkspaceSharingBuilder builder = getGWTWorkspaceBuilder();
|
||||||
|
|
||||||
if(isTestMode()){
|
if(isTestMode()){
|
||||||
logger.warn("WORKSPACE PORTLET IS IN TEST MODE - RETURN TEST USERS AND GROUPS");
|
logger.warn("WORKSPACE PORTLET IS IN TEST MODE - RETURN TEST USERS AND GROUPS");
|
||||||
GWTWorkspaceSharingBuilder.getHashTestUsers();
|
GWTWorkspaceSharingBuilder.getHashTestUsers();
|
||||||
|
@ -138,10 +138,10 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
List<InfoContactModel> listContactsModel = builder.buildGXTListContactsModelFromUserModel(userManag.listUsersByGroup(groupId));
|
List<InfoContactModel> listContactsModel = builder.buildGXTListContactsModelFromUserModel(userManag.listUsersByGroup(groupId));
|
||||||
*/
|
*/
|
||||||
List<UserModel> users = UserUtil.getOrganizationUsers(aslSession.getScope());
|
List<UserModel> users = UserUtil.getOrganizationUsers(aslSession.getScope());
|
||||||
|
|
||||||
if(users==null)
|
if(users==null)
|
||||||
throw new Exception("An error occurred on recovering users from Portal, try again later");
|
throw new Exception("An error occurred on recovering users from Portal, try again later");
|
||||||
|
|
||||||
List<InfoContactModel> listContactsModel = builder.buildGXTListContactsModelFromUserModel(users);
|
List<InfoContactModel> listContactsModel = builder.buildGXTListContactsModelFromUserModel(users);
|
||||||
|
|
||||||
if(readGroupsFromHL){
|
if(readGroupsFromHL){
|
||||||
|
@ -154,18 +154,18 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
listContactsModel.addAll(builder.buildGXTListContactsModelFromGcubeGroup(groups));
|
listContactsModel.addAll(builder.buildGXTListContactsModelFromGcubeGroup(groups));
|
||||||
}else
|
}else
|
||||||
logger.warn("Read group names from HL, return list null, skipping");
|
logger.warn("Read group names from HL, return list null, skipping");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(readGroupsFromPortal){
|
if(readGroupsFromPortal){
|
||||||
logger.info("Reading group names as scopes from Infrastructure..");
|
logger.info("Reading group names as scopes from Infrastructure..");
|
||||||
|
|
||||||
PortalContext context = PortalContext.getConfiguration();
|
PortalContext context = PortalContext.getConfiguration();
|
||||||
logger.info("context.getInfrastructureName(): "+context.getInfrastructureName());
|
logger.info("context.getInfrastructureName(): "+context.getInfrastructureName());
|
||||||
logger.info("aslSession.getGroupName(): "+ aslSession.getGroupName());
|
logger.info("aslSession.getGroupName(): "+ aslSession.getGroupName());
|
||||||
logger.info("aslSession.getScope().toString(): "+ aslSession.getScope());
|
logger.info("aslSession.getScope().toString(): "+ aslSession.getScope());
|
||||||
try{
|
try{
|
||||||
ScopeUtility scopeUtility = new ScopeUtility(aslSession.getScope());
|
ScopeUtility scopeUtility = new ScopeUtility(aslSession.getScope());
|
||||||
|
|
||||||
if(scopeUtility.getVoName()!=null){
|
if(scopeUtility.getVoName()!=null){
|
||||||
logger.info("VO name is not null, trying to calculate List VO");
|
logger.info("VO name is not null, trying to calculate List VO");
|
||||||
List<VO> lsVOs = WsUtil.getVresFromInfrastructure(context.getInfrastructureName(), scopeUtility.getVoName());
|
List<VO> lsVOs = WsUtil.getVresFromInfrastructure(context.getInfrastructureName(), scopeUtility.getVoName());
|
||||||
|
@ -173,15 +173,15 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
listContactsModel.addAll(builder.buildGXTListContactsModelFromVOs(lsVOs, scopeUtility.getVo()));
|
listContactsModel.addAll(builder.buildGXTListContactsModelFromVOs(lsVOs, scopeUtility.getVo()));
|
||||||
}else
|
}else
|
||||||
logger.warn("VO name is null, skipping list VO "+ aslSession.getGroupName());
|
logger.warn("VO name is null, skipping list VO "+ aslSession.getGroupName());
|
||||||
|
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
logger.warn("An error occurred on recovering vo name, skipping list VO "+ aslSession.getGroupName());
|
logger.warn("An error occurred on recovering vo name, skipping list VO "+ aslSession.getGroupName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Get all contacts returning a list having size: "+listContactsModel.size());
|
logger.info("Get all contacts returning a list having size: "+listContactsModel.size());
|
||||||
return listContactsModel;
|
return listContactsModel;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error in server get all contacts ", e);
|
logger.error("Error in server get all contacts ", e);
|
||||||
// return new ArrayList<InfoContactModel>();
|
// return new ArrayList<InfoContactModel>();
|
||||||
|
@ -194,17 +194,17 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<InfoContactModel> getListUserSharedByFolderSharedId(String folderSharedId) throws Exception{
|
public List<InfoContactModel> getListUserSharedByFolderSharedId(String folderSharedId) throws Exception{
|
||||||
|
|
||||||
logger.info("getListUserSharedByFolderSharedId "+ folderSharedId);
|
logger.info("getListUserSharedByFolderSharedId "+ folderSharedId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Workspace workspace = getWorkspace();
|
Workspace workspace = getWorkspace();
|
||||||
|
|
||||||
WorkspaceItem wsItem = workspace.getItem(folderSharedId);
|
WorkspaceItem wsItem = workspace.getItem(folderSharedId);
|
||||||
|
|
||||||
//TODO CHANGE TO READ ACL FROM SHARED SUBFOLDER
|
//TODO CHANGE TO READ ACL FROM SHARED SUBFOLDER
|
||||||
if(isASharedFolder(wsItem, false)){
|
if(isASharedFolder(wsItem, false)){
|
||||||
|
|
||||||
WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) workspace.getItem(wsItem.getIdSharedFolder());
|
WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) workspace.getItem(wsItem.getIdSharedFolder());
|
||||||
|
|
||||||
GWTWorkspaceSharingBuilder builder = getGWTWorkspaceBuilder();
|
GWTWorkspaceSharingBuilder builder = getGWTWorkspaceBuilder();
|
||||||
|
@ -215,13 +215,13 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
|
|
||||||
if(isTestMode())
|
if(isTestMode())
|
||||||
return builder.buildGxtInfoContactFromPortalLoginTestMode(listPortalLogin);
|
return builder.buildGxtInfoContactFromPortalLoginTestMode(listPortalLogin);
|
||||||
|
|
||||||
return builder.buildGxtInfoContactsFromPortalLogins(listPortalLogin);
|
return builder.buildGxtInfoContactsFromPortalLogins(listPortalLogin);
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
logger.info("the item with id: "+folderSharedId+ " is not "+WorkspaceItemType.SHARED_FOLDER);
|
logger.info("the item with id: "+folderSharedId+ " is not "+WorkspaceItemType.SHARED_FOLDER);
|
||||||
|
|
||||||
//DEBUG
|
//DEBUG
|
||||||
//System.out.println("the item with id: "+folderSharedId+ " is not "+WorkspaceItemType.SHARED_FOLDER);
|
//System.out.println("the item with id: "+folderSharedId+ " is not "+WorkspaceItemType.SHARED_FOLDER);
|
||||||
}
|
}
|
||||||
|
@ -234,30 +234,30 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
throw new Exception(e.getMessage());
|
throw new Exception(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingService#getOwnerByItemId(java.lang.String)
|
* @see org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingService#getOwnerByItemId(java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public InfoContactModel getOwnerByItemId(String itemId) throws Exception {
|
public InfoContactModel getOwnerByItemId(String itemId) throws Exception {
|
||||||
|
|
||||||
logger.info("get Owner By ItemId "+ itemId);
|
logger.info("get Owner By ItemId "+ itemId);
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Workspace workspace = getWorkspace();
|
Workspace workspace = getWorkspace();
|
||||||
|
|
||||||
WorkspaceItem wsItem = workspace.getItem(itemId);
|
WorkspaceItem wsItem = workspace.getItem(itemId);
|
||||||
|
|
||||||
GWTWorkspaceSharingBuilder builder = getGWTWorkspaceBuilder();
|
GWTWorkspaceSharingBuilder builder = getGWTWorkspaceBuilder();
|
||||||
|
|
||||||
return builder.buildGXTInfoContactModel(wsItem.getOwner());
|
return builder.buildGXTInfoContactModel(wsItem.getOwner());
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error in getOwnerByItemId ", e);
|
logger.error("Error in getOwnerByItemId ", e);
|
||||||
throw new Exception(e.getMessage());
|
throw new Exception(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the AC ls.
|
* Gets the AC ls.
|
||||||
*
|
*
|
||||||
|
@ -276,7 +276,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
throw new Exception(error);
|
throw new Exception(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingService#getMyLogin()
|
* @see org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingService#getMyLogin()
|
||||||
*/
|
*/
|
||||||
|
@ -285,7 +285,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
ASLSession asl = WsUtil.getAslSession(this.getThreadLocalRequest().getSession());
|
ASLSession asl = WsUtil.getAslSession(this.getThreadLocalRequest().getSession());
|
||||||
return asl.getUsername();
|
return asl.getUsername();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingService#getFileModelByWorkpaceItemId(java.lang.String)
|
* @see org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingService#getFileModelByWorkpaceItemId(java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
@ -293,35 +293,35 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
public FileModel getFileModelByWorkpaceItemId(String itemId) throws Exception {
|
public FileModel getFileModelByWorkpaceItemId(String itemId) throws Exception {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// System.out.println("Get file model by itemId: "+itemId);
|
// System.out.println("Get file model by itemId: "+itemId);
|
||||||
|
|
||||||
if(itemId == null || itemId.isEmpty())
|
if(itemId == null || itemId.isEmpty())
|
||||||
throw new Exception("Identifier is null or empty");
|
throw new Exception("Identifier is null or empty");
|
||||||
|
|
||||||
Workspace workspace = getWorkspace();
|
Workspace workspace = getWorkspace();
|
||||||
|
|
||||||
logger.info("Get file model by itemId: "+itemId);
|
logger.info("Get file model by itemId: "+itemId);
|
||||||
|
|
||||||
WorkspaceItem wsItem = workspace.getItem(itemId);
|
WorkspaceItem wsItem = workspace.getItem(itemId);
|
||||||
|
|
||||||
GWTWorkspaceSharingBuilder builder = getGWTWorkspaceBuilder();
|
GWTWorkspaceSharingBuilder builder = getGWTWorkspaceBuilder();
|
||||||
|
|
||||||
// Long startTime = System.currentTimeMillis();
|
// Long startTime = System.currentTimeMillis();
|
||||||
//
|
//
|
||||||
// Long endTime = System.currentTimeMillis() - startTime;
|
// Long endTime = System.currentTimeMillis() - startTime;
|
||||||
// String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
|
// String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
|
||||||
// logger.debug("get child for Grid by id returning element in " + time);
|
// logger.debug("get child for Grid by id returning element in " + time);
|
||||||
|
|
||||||
logger.info("Getting folder parent");
|
logger.info("Getting folder parent");
|
||||||
|
|
||||||
WorkspaceFolder folderParent = null;
|
WorkspaceFolder folderParent = null;
|
||||||
if(wsItem!=null)
|
if(wsItem!=null)
|
||||||
folderParent = wsItem.getParent(); //BUILD PARENT
|
folderParent = wsItem.getParent(); //BUILD PARENT
|
||||||
else
|
else
|
||||||
throw new Exception("Workspace item not found");
|
throw new Exception("Workspace item not found");
|
||||||
|
|
||||||
|
|
||||||
FileModel parent = null;
|
FileModel parent = null;
|
||||||
if(folderParent!=null){
|
if(folderParent!=null){
|
||||||
logger.info("Folder parent has id: "+folderParent.getId() + " and name: "+folderParent.getName());
|
logger.info("Folder parent has id: "+folderParent.getId() + " and name: "+folderParent.getName());
|
||||||
|
@ -329,7 +329,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
logger.info("Folder parent for item: "+wsItem.getId() +" is null");
|
logger.info("Folder parent for item: "+wsItem.getId() +" is null");
|
||||||
|
|
||||||
//BUILD ITEM
|
//BUILD ITEM
|
||||||
return builder.buildGXTFileModelItem(wsItem, parent);
|
return builder.buildGXTFileModelItem(wsItem, parent);
|
||||||
}catch (ItemNotFoundException e){
|
}catch (ItemNotFoundException e){
|
||||||
|
@ -341,7 +341,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
throw new Exception(error);
|
throw new Exception(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#isSessionExpired()
|
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#isSessionExpired()
|
||||||
*/
|
*/
|
||||||
|
@ -350,7 +350,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
return WsUtil.isSessionExpired(this.getThreadLocalRequest().getSession());
|
return WsUtil.isSessionExpired(this.getThreadLocalRequest().getSession());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
/**
|
/**
|
||||||
* Prints the contacts.
|
* Prints the contacts.
|
||||||
|
@ -373,25 +373,25 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingService#shareFolder(org.gcube.portlets.widgets.workspacesharingwidget.shared.FileModel, java.util.List, boolean, org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL)
|
* @see org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingService#shareFolder(org.gcube.portlets.widgets.workspacesharingwidget.shared.FileModel, java.util.List, boolean, org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean shareFolder(FileModel folder, List<InfoContactModel> listContacts, boolean isNewFolder, WorkspaceACL acl) throws Exception {
|
public boolean shareFolder(FileModel folder, List<InfoContactModel> listContacts, boolean isNewFolder, WorkspaceACL acl) throws Exception {
|
||||||
|
|
||||||
if(isSessionExpired())
|
if(isSessionExpired())
|
||||||
throw new SessionExpiredException();
|
throw new SessionExpiredException();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Workspace workspace = getWorkspace();
|
Workspace workspace = getWorkspace();
|
||||||
|
|
||||||
logger.info("sharing item id: "+ folder.getIdentifier()
|
logger.info("sharing item id: "+ folder.getIdentifier()
|
||||||
+ " name: "+ folder.getName()
|
+ " name: "+ folder.getName()
|
||||||
// + " parent name: " + folder.getParentFileModel().getName()
|
// + " parent name: " + folder.getParentFileModel().getName()
|
||||||
+ " listContacts size: " + listContacts.size());
|
+ " listContacts size: " + listContacts.size());
|
||||||
|
|
||||||
// //DEBUG
|
// //DEBUG
|
||||||
//System.out.println("shareFolder "+ folder.getIdentifier() + " name: "+ folder.getName() + " parent name: " + folder.getParentFileModel().getName() + " listContacts size: " + listContacts.size());
|
//System.out.println("shareFolder "+ folder.getIdentifier() + " name: "+ folder.getName() + " parent name: " + folder.getParentFileModel().getName() + " listContacts size: " + listContacts.size());
|
||||||
// for (InfoContactModel infoContactModel : listContacts) {
|
// for (InfoContactModel infoContactModel : listContacts) {
|
||||||
|
@ -400,19 +400,19 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
// printContacts(listContacts);
|
// printContacts(listContacts);
|
||||||
|
|
||||||
List<String> listLogin = UserUtil.getListLoginByInfoContactModel(listContacts);
|
List<String> listLogin = UserUtil.getListLoginByInfoContactModel(listContacts);
|
||||||
|
|
||||||
WorkspaceSharedFolder sharedFolder = null;
|
WorkspaceSharedFolder sharedFolder = null;
|
||||||
|
|
||||||
List<InfoContactModel> listSharedContact = null;
|
List<InfoContactModel> listSharedContact = null;
|
||||||
|
|
||||||
boolean sourceFolderIsShared = folder.isShared();
|
boolean sourceFolderIsShared = folder.isShared();
|
||||||
|
|
||||||
if(sourceFolderIsShared){ //if source folder is already share... retrieve old list of sharing to notify
|
if(sourceFolderIsShared){ //if source folder is already share... retrieve old list of sharing to notify
|
||||||
listSharedContact = getListUserSharedByFolderSharedId(folder.getIdentifier());
|
listSharedContact = getListUserSharedByFolderSharedId(folder.getIdentifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(listLogin.size()>0){
|
if(listLogin.size()>0){
|
||||||
|
|
||||||
if(!isNewFolder){
|
if(!isNewFolder){
|
||||||
sharedFolder = workspace.shareFolder(listLogin, folder.getIdentifier());
|
sharedFolder = workspace.shareFolder(listLogin, folder.getIdentifier());
|
||||||
sharedFolder.setDescription(folder.getDescription()); //SET NEW DESCRIPTION
|
sharedFolder.setDescription(folder.getDescription()); //SET NEW DESCRIPTION
|
||||||
|
@ -420,42 +420,42 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
else
|
else
|
||||||
sharedFolder = workspace.createSharedFolder(folder.getName(), folder.getDescription(), listLogin, folder.getParentFileModel().getIdentifier());
|
sharedFolder = workspace.createSharedFolder(folder.getName(), folder.getDescription(), listLogin, folder.getParentFileModel().getIdentifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean created = sharedFolder==null?false:true;
|
boolean created = sharedFolder==null?false:true;
|
||||||
|
|
||||||
if(acl!=null)
|
if(acl!=null)
|
||||||
setACLs(sharedFolder.getId(), listLogin, acl.getId().toString());
|
setACLs(sharedFolder.getId(), listLogin, acl.getId().toString());
|
||||||
|
|
||||||
if(created){
|
if(created){
|
||||||
NotificationsProducer np = getNotificationProducer();
|
NotificationsProducer np = getNotificationProducer();
|
||||||
if(!sourceFolderIsShared) {//if source folder is not already shared
|
if(!sourceFolderIsShared) {//if source folder is not already shared
|
||||||
|
|
||||||
//TODO ADD NOTIFICATION
|
//TODO ADD NOTIFICATION
|
||||||
// np.notifyFolderSharing(listContacts, sharedFolder);
|
// np.notifyFolderSharing(listContacts, sharedFolder);
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
/*System.out.println("SHARED CONTACS: ");
|
/*System.out.println("SHARED CONTACS: ");
|
||||||
printContacts(listSharedContact);
|
printContacts(listSharedContact);
|
||||||
System.out.println("NEW CONTACS: ");
|
System.out.println("NEW CONTACS: ");
|
||||||
printContacts(listContacts);*/
|
printContacts(listContacts);*/
|
||||||
|
|
||||||
//TODO ADD NOTIFICATION
|
//TODO ADD NOTIFICATION
|
||||||
// np.notifyAddedUsersToSharing(listSharedContact, listContacts, sharedFolder);
|
// np.notifyAddedUsersToSharing(listSharedContact, listContacts, sharedFolder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return created;
|
return created;
|
||||||
|
|
||||||
} catch (InsufficientPrivilegesException e) {
|
} catch (InsufficientPrivilegesException e) {
|
||||||
logger.error("Error in shareFolder ", e);
|
logger.error("Error in shareFolder ", e);
|
||||||
String error = "An error occurred on creating shared folder. "+ e.getMessage();
|
String error = "An error occurred on creating shared folder. "+ e.getMessage();
|
||||||
throw new Exception(error);
|
throw new Exception(error);
|
||||||
|
|
||||||
} catch (ItemAlreadyExistException e) {
|
} catch (ItemAlreadyExistException e) {
|
||||||
logger.error("Error in shareFolder ", e);
|
logger.error("Error in shareFolder ", e);
|
||||||
String error = "An error occurred on creating shared folder. "+ e.getMessage();
|
String error = "An error occurred on creating shared folder. "+ e.getMessage();
|
||||||
throw new Exception(error);
|
throw new Exception(error);
|
||||||
|
|
||||||
} catch (WrongDestinationException e) {
|
} catch (WrongDestinationException e) {
|
||||||
logger.error("Error in shareFolder ", e);
|
logger.error("Error in shareFolder ", e);
|
||||||
String error = "An error occurred on creating shared folder. "+ e.getMessage();
|
String error = "An error occurred on creating shared folder. "+ e.getMessage();
|
||||||
|
@ -468,7 +468,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
throw new Exception(error);
|
throw new Exception(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the ac ls.
|
* Sets the ac ls.
|
||||||
*
|
*
|
||||||
|
@ -481,34 +481,34 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if(folderId == null)
|
if(folderId == null)
|
||||||
throw new Exception("Folder id is null");
|
throw new Exception("Folder id is null");
|
||||||
|
|
||||||
if(listLogins==null || listLogins.size()==0)
|
if(listLogins==null || listLogins.size()==0)
|
||||||
throw new Exception("List Logins is null or empty");
|
throw new Exception("List Logins is null or empty");
|
||||||
|
|
||||||
logger.info("Setting ACL for folder id: "+folderId);
|
logger.info("Setting ACL for folder id: "+folderId);
|
||||||
logger.info("ACL type is: "+aclType);
|
logger.info("ACL type is: "+aclType);
|
||||||
|
|
||||||
Workspace workspace = getWorkspace();
|
Workspace workspace = getWorkspace();
|
||||||
WorkspaceItem wsItem = workspace.getItem(folderId);
|
WorkspaceItem wsItem = workspace.getItem(folderId);
|
||||||
|
|
||||||
//IS A WORKSPACE FOLDER?
|
//IS A WORKSPACE FOLDER?
|
||||||
if(wsItem!= null && wsItem.isFolder() && wsItem.isShared()){
|
if(wsItem!= null && wsItem.isFolder() && wsItem.isShared()){
|
||||||
WorkspaceFolder ite;
|
WorkspaceFolder ite;
|
||||||
if(wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
if(wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
||||||
//IS ROOT SHARED FOLDER
|
//IS ROOT SHARED FOLDER
|
||||||
ite = (WorkspaceSharedFolder) wsItem;
|
ite = (WorkspaceSharedFolder) wsItem;
|
||||||
logger.trace("Folder " +ite.getName()+" is a "+WorkspaceSharedFolder.class.getName());
|
logger.trace("Folder " +ite.getName()+" is a "+WorkspaceSharedFolder.class.getName());
|
||||||
}else{
|
}else{
|
||||||
// IS SUB FOLDER OF THE SHARING
|
// IS SUB FOLDER OF THE SHARING
|
||||||
ite = (WorkspaceFolder) wsItem;
|
ite = (WorkspaceFolder) wsItem;
|
||||||
logger.trace("Folder " +ite.getName()+" is a "+WorkspaceFolder.class.getName());
|
logger.trace("Folder " +ite.getName()+" is a "+WorkspaceFolder.class.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
ite.setACL(listLogins, ACLType.valueOf(aclType));
|
ite.setACL(listLogins, ACLType.valueOf(aclType));
|
||||||
}else
|
}else
|
||||||
throw new Exception("Source item is not shared or shared folder");
|
throw new Exception("Source item is not shared or shared folder");
|
||||||
|
|
||||||
logger.info("Setting ACL for "+wsItem.getName()+" completed, returning");
|
logger.info("Setting ACL for "+wsItem.getName()+" completed, returning");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.info("Error in set ACLs", e);
|
logger.info("Error in set ACLs", e);
|
||||||
|
@ -522,49 +522,55 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<InfoContactModel> getInfoContactModelsFromCredential(List<CredentialModel> listAlreadySharedContact) throws Exception {
|
public List<InfoContactModel> getInfoContactModelsFromCredential(List<CredentialModel> listAlreadySharedContact) throws Exception {
|
||||||
|
|
||||||
if(listAlreadySharedContact==null || listAlreadySharedContact.size()==0)
|
if(listAlreadySharedContact==null || listAlreadySharedContact.size()==0)
|
||||||
throw new Exception("Credentials list is null or empty");
|
throw new Exception("Credentials list is null or empty");
|
||||||
|
|
||||||
|
|
||||||
GWTWorkspaceSharingBuilder builder = getGWTWorkspaceBuilder();
|
GWTWorkspaceSharingBuilder builder = getGWTWorkspaceBuilder();
|
||||||
List<InfoContactModel> listContacts = new ArrayList<InfoContactModel>(listAlreadySharedContact.size());
|
List<InfoContactModel> listContacts = new ArrayList<InfoContactModel>(listAlreadySharedContact.size());
|
||||||
for (CredentialModel credentialModel : listAlreadySharedContact) {
|
for (CredentialModel credentialModel : listAlreadySharedContact) {
|
||||||
|
|
||||||
if(!credentialModel.isGroup()){
|
if(!credentialModel.isGroup()){
|
||||||
InfoContactModel contact = builder.buildGxtInfoContactFromPortalLogin(credentialModel.getLogin());
|
InfoContactModel contact = builder.buildGxtInfoContactFromPortalLogin(credentialModel.getLogin());
|
||||||
contact.setReferenceCredential(credentialModel);
|
contact.setReferenceCredential(credentialModel);
|
||||||
listContacts.add(contact);
|
listContacts.add(contact);
|
||||||
|
logger.trace("Converted contact: "+credentialModel +", into: "+contact);
|
||||||
|
}else if(credentialModel.getName()==null || credentialModel.getName().isEmpty()){
|
||||||
|
InfoContactModel contact = builder.buildGxtInfoContactFromPortalGroup(credentialModel.getLogin());
|
||||||
|
contact.setReferenceCredential(credentialModel);
|
||||||
|
listContacts.add(contact);
|
||||||
|
logger.trace("Converted group: "+credentialModel +", into: "+contact);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return listContacts;
|
return listContacts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingService#getAdministratorsByFolderId(java.lang.String)
|
* @see org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingService#getAdministratorsByFolderId(java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<InfoContactModel> getAdministratorsByFolderId(String sharedFolderId) throws Exception {
|
public List<InfoContactModel> getAdministratorsByFolderId(String sharedFolderId) throws Exception {
|
||||||
|
|
||||||
if(sharedFolderId==null || sharedFolderId.isEmpty())
|
if(sharedFolderId==null || sharedFolderId.isEmpty())
|
||||||
throw new Exception("Shared Folder id is null or empty");
|
throw new Exception("Shared Folder id is null or empty");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Workspace workspace = getWorkspace();
|
Workspace workspace = getWorkspace();
|
||||||
WorkspaceItem item = workspace.getItem(sharedFolderId);
|
WorkspaceItem item = workspace.getItem(sharedFolderId);
|
||||||
logger.info("Getting administator/s to folder: "+sharedFolderId);
|
logger.info("Getting administator/s to folder: "+sharedFolderId);
|
||||||
|
|
||||||
if(item!=null && item.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
if(item!=null && item.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
||||||
WorkspaceSharedFolder sharedFolder = (WorkspaceSharedFolder) item;
|
WorkspaceSharedFolder sharedFolder = (WorkspaceSharedFolder) item;
|
||||||
GWTWorkspaceSharingBuilder builder = getGWTWorkspaceBuilder();
|
GWTWorkspaceSharingBuilder builder = getGWTWorkspaceBuilder();
|
||||||
List<String> admins = sharedFolder.getAdministrators();
|
List<String> admins = sharedFolder.getAdministrators();
|
||||||
logger.info("Converting "+admins.size()+" administator/s List<InfoContactModel>");
|
logger.info("Converting "+admins.size()+" administator/s List<InfoContactModel>");
|
||||||
|
|
||||||
if(isTestMode())
|
if(isTestMode())
|
||||||
return builder.buildGxtInfoContactFromPortalLoginTestMode(admins);
|
return builder.buildGxtInfoContactFromPortalLoginTestMode(admins);
|
||||||
|
|
||||||
return builder.buildGxtInfoContactsFromPortalLogins(admins);
|
return builder.buildGxtInfoContactsFromPortalLogins(admins);
|
||||||
}else
|
}else
|
||||||
throw new Exception("The item is null or not instanceof "+WorkspaceItemType.SHARED_FOLDER);
|
throw new Exception("The item is null or not instanceof "+WorkspaceItemType.SHARED_FOLDER);
|
||||||
|
@ -577,75 +583,37 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
throw new Exception(error);
|
throw new Exception(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DEBUG.
|
* DEBUG.
|
||||||
*
|
*
|
||||||
* @return the fake groups
|
* @return the fake groups
|
||||||
*/
|
*/
|
||||||
private List<InfoContactModel> getFakeGroups(){
|
private List<InfoContactModel> getFakeGroups(){
|
||||||
|
|
||||||
List<InfoContactModel> listContactsModel = new ArrayList<InfoContactModel>();
|
List<InfoContactModel> listContactsModel = new ArrayList<InfoContactModel>();
|
||||||
|
|
||||||
PortalContext context = PortalContext.getConfiguration();
|
PortalContext context = PortalContext.getConfiguration();
|
||||||
System.out.println("context.getInfrastructureName(): "+context.getInfrastructureName());
|
System.out.println("context.getInfrastructureName(): "+context.getInfrastructureName());
|
||||||
// System.out.println("context.getVOsAsString(): "+context.getVOsAsString());
|
// System.out.println("context.getVOsAsString(): "+context.getVOsAsString());
|
||||||
List<VO> vos = WsUtil.getVresFromInfrastructure(context.getInfrastructureName(), "devsec");
|
List<VO> vos = WsUtil.getVresFromInfrastructure(context.getInfrastructureName(), "devsec");
|
||||||
|
|
||||||
for (VO vo : vos) {
|
for (VO vo : vos) {
|
||||||
System.out.println("vo name "+vo.getName());
|
System.out.println("vo name "+vo.getName());
|
||||||
|
|
||||||
for (VRE vre : vo.getVres()) {
|
for (VRE vre : vo.getVres()) {
|
||||||
System.out.println("vre name "+vre.getName());
|
System.out.println("vre name "+vre.getName());
|
||||||
listContactsModel.add(new InfoContactModel(vre.getName(), vre.getName(), vre.getName(), true));
|
listContactsModel.add(new InfoContactModel(vre.getName(), vre.getName(), vre.getName(), true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return listContactsModel;
|
return listContactsModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The main method.
|
|
||||||
*
|
|
||||||
* @param args the arguments
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
|
||||||
|
|
||||||
WorkspaceSharingServiceImpl impl = new WorkspaceSharingServiceImpl();
|
|
||||||
|
|
||||||
PortalContext context = PortalContext.getConfiguration();
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
String nameVO = "devsec";
|
|
||||||
String vrePath = ConstantsSharing.PATH_SEPARATOR+context.getInfrastructureName() + ConstantsSharing.PATH_SEPARATOR + nameVO + ConstantsSharing.PATH_SEPARATOR;
|
|
||||||
|
|
||||||
List<VO> lsVOs = WsUtil.getVresFromInfrastructure(context.getInfrastructureName(), nameVO);
|
|
||||||
GWTWorkspaceSharingBuilder builder = new GWTWorkspaceSharingBuilder();
|
|
||||||
List<InfoContactModel> groups = builder.buildGXTListContactsModelFromVOs(lsVOs, vrePath);
|
|
||||||
|
|
||||||
for (VO vo : lsVOs) {
|
|
||||||
System.out.println(vo.getName());
|
|
||||||
|
|
||||||
for (VRE vre : vo.getVres()) {
|
|
||||||
System.out.println("VRE: "+vre.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (InfoContactModel infoContactModel : groups) {
|
|
||||||
System.out.println(infoContactModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingService#getACLForSharedItemId(java.lang.String)
|
* @see org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingService#getACLForSharedItemId(java.lang.String)
|
||||||
*
|
*
|
||||||
* return the WorkspaceACL of shared folder, null otherwise
|
* return the WorkspaceACL of shared folder, null otherwise
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -656,38 +624,38 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Workspace workspace = getWorkspace();
|
Workspace workspace = getWorkspace();
|
||||||
WorkspaceItem item = workspace.getItem(itemID);
|
WorkspaceItem item = workspace.getItem(itemID);
|
||||||
|
|
||||||
if(isASharedFolder(item, false)){ //IS A SHARED FOLDER
|
if(isASharedFolder(item, false)){ //IS A SHARED FOLDER
|
||||||
|
|
||||||
//TODO REMOVE PARENT SHARED FOLDER
|
//TODO REMOVE PARENT SHARED FOLDER
|
||||||
// WorkspaceSharedFolder parentSharedFolder = (WorkspaceSharedFolder) workspace.getItem(item.getIdSharedFolder());
|
// WorkspaceSharedFolder parentSharedFolder = (WorkspaceSharedFolder) workspace.getItem(item.getIdSharedFolder());
|
||||||
WorkspaceSharedFolder sharedFolder = (WorkspaceSharedFolder) item;
|
WorkspaceSharedFolder sharedFolder = (WorkspaceSharedFolder) item;
|
||||||
GWTWorkspaceSharingBuilder builder = getGWTWorkspaceBuilder();
|
GWTWorkspaceSharingBuilder builder = getGWTWorkspaceBuilder();
|
||||||
|
|
||||||
logger.info("Read getPrivilege from HL: "+sharedFolder.getACLUser());
|
logger.info("Read getPrivilege from HL: "+sharedFolder.getACLUser());
|
||||||
List<WorkspaceACL> wsAcls = builder.getWorkspaceACLFromACLs(Arrays.asList(sharedFolder.getACLUser()));
|
List<WorkspaceACL> wsAcls = builder.getWorkspaceACLFromACLs(Arrays.asList(sharedFolder.getACLUser()));
|
||||||
|
|
||||||
if(wsAcls==null || wsAcls.isEmpty()){
|
if(wsAcls==null || wsAcls.isEmpty()){
|
||||||
logger.info("Converted ACLBySharedFolderId is null or empty, returning null");
|
logger.info("Converted ACLBySharedFolderId is null or empty, returning null");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Returning first acl with id: "+wsAcls.get(0).getId());
|
logger.info("Returning first acl with id: "+wsAcls.get(0).getId());
|
||||||
return wsAcls.get(0);
|
return wsAcls.get(0);
|
||||||
|
|
||||||
}else
|
}else
|
||||||
throw new Exception("The item is null or not a shared folder");
|
throw new Exception("The item is null or not a shared folder");
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error in server getACLForSharedItemId", e);
|
logger.error("Error in server getACLForSharedItemId", e);
|
||||||
String error = "Sorry an error occurred when getting ACL for item: "+itemID;
|
String error = "Sorry an error occurred when getting ACL for item: "+itemID;
|
||||||
throw new Exception(error);
|
throw new Exception(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the AC ls description for shared folder id.
|
* Gets the AC ls description for shared folder id.
|
||||||
*
|
*
|
||||||
|
@ -698,7 +666,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
@Override
|
@Override
|
||||||
public String getACLsDescriptionForSharedFolderId(String folderId) throws Exception{
|
public String getACLsDescriptionForSharedFolderId(String folderId) throws Exception{
|
||||||
try {
|
try {
|
||||||
|
|
||||||
WorkspaceFolder wsFolder = getSharedFolderForId(folderId);
|
WorkspaceFolder wsFolder = getSharedFolderForId(folderId);
|
||||||
GWTWorkspaceSharingBuilder builder = getGWTWorkspaceBuilder();
|
GWTWorkspaceSharingBuilder builder = getGWTWorkspaceBuilder();
|
||||||
return builder.getFormattedHtmlACLFromACLs(wsFolder.getACLOwner());
|
return builder.getFormattedHtmlACLFromACLs(wsFolder.getACLOwner());
|
||||||
|
@ -708,7 +676,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
throw new Exception(error);
|
throw new Exception(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the shared folder for id.
|
* Gets the shared folder for id.
|
||||||
*
|
*
|
||||||
|
@ -717,36 +685,36 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
private WorkspaceFolder getSharedFolderForId(String folderId) throws Exception{
|
private WorkspaceFolder getSharedFolderForId(String folderId) throws Exception{
|
||||||
|
|
||||||
if(folderId == null)
|
if(folderId == null)
|
||||||
throw new Exception("Folder id is null");
|
throw new Exception("Folder id is null");
|
||||||
|
|
||||||
logger.trace("Get SharedFolderForId: "+folderId);
|
logger.trace("Get SharedFolderForId: "+folderId);
|
||||||
|
|
||||||
Workspace workspace = getWorkspace();
|
Workspace workspace = getWorkspace();
|
||||||
WorkspaceItem wsItem = null;
|
WorkspaceItem wsItem = null;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
wsItem = workspace.getItem(folderId);
|
wsItem = workspace.getItem(folderId);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
logger.error("Get SharedFolderForId error on folder id: "+folderId, e);
|
logger.error("Get SharedFolderForId error on folder id: "+folderId, e);
|
||||||
throw new Exception("Sorry, an error has occurred on the server when retrieving item with id: "+folderId+". Try again later!");
|
throw new Exception("Sorry, an error has occurred on the server when retrieving item with id: "+folderId+". Try again later!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isASharedFolder(wsItem, false)){
|
if(isASharedFolder(wsItem, false)){
|
||||||
logger.trace("Get SharedFolderForId: folder id "+folderId+" is shared");
|
logger.trace("Get SharedFolderForId: folder id "+folderId+" is shared");
|
||||||
|
|
||||||
//TODO REMOVE wsItem.getIdSharedFolder()
|
//TODO REMOVE wsItem.getIdSharedFolder()
|
||||||
// WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) workspace.getItem(wsItem.getIdSharedFolder());
|
// WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) workspace.getItem(wsItem.getIdSharedFolder());
|
||||||
WorkspaceFolder wsFolder = (WorkspaceFolder) workspace.getItem(wsItem.getId());
|
WorkspaceFolder wsFolder = (WorkspaceFolder) workspace.getItem(wsItem.getId());
|
||||||
|
|
||||||
if(wsFolder!=null){
|
if(wsFolder!=null){
|
||||||
logger.info("Get SharedFolderForId return name: "+wsFolder.getName());
|
logger.info("Get SharedFolderForId return name: "+wsFolder.getName());
|
||||||
return wsFolder;
|
return wsFolder;
|
||||||
|
|
||||||
//TODO USE THIS
|
//TODO USE THIS
|
||||||
// return (WorkspaceFolder) wsItem;
|
// return (WorkspaceFolder) wsItem;
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
logger.warn("Source item is not a shared folder, throw exception");
|
logger.warn("Source item is not a shared folder, throw exception");
|
||||||
throw new Exception("Source item is not a shared folder");
|
throw new Exception("Source item is not a shared folder");
|
||||||
|
@ -756,7 +724,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
throw new Exception("Source item is null or not shared for id: "+folderId);
|
throw new Exception("Source item is null or not shared for id: "+folderId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if is a shared folder.
|
* Checks if is a shared folder.
|
||||||
*
|
*
|
||||||
|
@ -764,24 +732,24 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
* @param asRoot true check if itemID is root, not otherwise
|
* @param asRoot true check if itemID is root, not otherwise
|
||||||
* @return true, if is a shared folder
|
* @return true, if is a shared folder
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public boolean isASharedFolder(String itemID, boolean asRoot){
|
public boolean isASharedFolder(String itemID, boolean asRoot){
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if(itemID==null)
|
if(itemID==null)
|
||||||
throw new Exception("ItemId is null");
|
throw new Exception("ItemId is null");
|
||||||
|
|
||||||
Workspace workspace = getWorkspace();
|
Workspace workspace = getWorkspace();
|
||||||
WorkspaceItem item = workspace.getItem(itemID);
|
WorkspaceItem item = workspace.getItem(itemID);
|
||||||
|
|
||||||
return isASharedFolder(item, asRoot);
|
return isASharedFolder(item, asRoot);
|
||||||
|
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
logger.error("Error in server isASharedFolder", e);
|
logger.error("Error in server isASharedFolder", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if is a shared folder.
|
* Checks if is a shared folder.
|
||||||
*
|
*
|
||||||
|
@ -791,18 +759,95 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
*/
|
*/
|
||||||
public boolean isASharedFolder(WorkspaceItem item, boolean asRoot){
|
public boolean isASharedFolder(WorkspaceItem item, boolean asRoot){
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if(item!=null && item.isFolder() && item.isShared()){ //IS A SHARED SUB-FOLDER
|
if(item!=null && item.isFolder() && item.isShared()){ //IS A SHARED SUB-FOLDER
|
||||||
if(asRoot)
|
if(asRoot)
|
||||||
return item.getType().equals(WorkspaceItemType.SHARED_FOLDER); //IS ROOT?
|
return item.getType().equals(WorkspaceItemType.SHARED_FOLDER); //IS ROOT?
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
logger.error("Error in server isASharedFolder", e);
|
logger.error("Error in server isASharedFolder", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check list share name for group.
|
||||||
|
*
|
||||||
|
* @param listAlreadySharedContact the list already shared contact
|
||||||
|
* @return the list
|
||||||
|
*/
|
||||||
|
/*private static List<CredentialModel> checkShareNameForGroup(List<CredentialModel> listAlreadySharedContact){
|
||||||
|
|
||||||
|
if(listAlreadySharedContact==null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
for (CredentialModel credentialModel : listAlreadySharedContact) {
|
||||||
|
if(credentialModel.isGroup() && (credentialModel.getName()==null || credentialModel.getName().isEmpty())){
|
||||||
|
|
||||||
|
//RECOVERING VRE NAME
|
||||||
|
if(credentialModel.getLogin().contains("/")){
|
||||||
|
|
||||||
|
int start = credentialModel.getLogin().lastIndexOf("/");
|
||||||
|
int end = credentialModel.getLogin().length();
|
||||||
|
|
||||||
|
if(start<end){
|
||||||
|
credentialModel.setName(credentialModel.getLogin().substring(start+1, end));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return listAlreadySharedContact;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The main method.
|
||||||
|
*
|
||||||
|
* @param args the arguments
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
/*try {
|
||||||
|
String root="gcube";
|
||||||
|
String nameVO = "devsec";
|
||||||
|
String vrePath = ConstantsSharing.PATH_SEPARATOR+root + ConstantsSharing.PATH_SEPARATOR + nameVO + ConstantsSharing.PATH_SEPARATOR;
|
||||||
|
|
||||||
|
List<VO> lsVOs = WsUtil.getVresFromInfrastructure(root, nameVO);
|
||||||
|
GWTWorkspaceSharingBuilder builder = new GWTWorkspaceSharingBuilder();
|
||||||
|
List<InfoContactModel> groups = builder.buildGXTListContactsModelFromVOs(lsVOs, vrePath);
|
||||||
|
|
||||||
|
for (VO vo : lsVOs) {
|
||||||
|
System.out.println(vo.getName());
|
||||||
|
|
||||||
|
for (VRE vre : vo.getVres()) {
|
||||||
|
System.out.println("VRE: "+vre.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// for (InfoContactModel infoContactModel : groups) {
|
||||||
|
// System.out.println(infoContactModel);
|
||||||
|
// }
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/*List<CredentialModel> list = new ArrayList<CredentialModel>();
|
||||||
|
list.add(new CredentialModel(null, "test.user", false));
|
||||||
|
list.add(new CredentialModel(null, "/gcube/devsec/devVRE", true));
|
||||||
|
list.add(new CredentialModel(null, "francesco.mangiacrapa", false));
|
||||||
|
list.add(new CredentialModel(null, "devVRE", true));
|
||||||
|
list.add(new CredentialModel(null, "/gcube/devsec/NextNext", true));
|
||||||
|
|
||||||
|
list = checkListShareNameForGroup(list);
|
||||||
|
|
||||||
|
for (CredentialModel credentialModel : list) {
|
||||||
|
System.out.println(credentialModel);
|
||||||
|
}*/
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,6 @@ import org.gcube.vomanagement.usermanagement.model.UserModel;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class UserUtil.
|
* The Class UserUtil.
|
||||||
*
|
*
|
||||||
|
@ -26,11 +24,11 @@ import org.slf4j.LoggerFactory;
|
||||||
* Aug 3, 2015
|
* Aug 3, 2015
|
||||||
*/
|
*/
|
||||||
public class UserUtil {
|
public class UserUtil {
|
||||||
|
|
||||||
static UserManager um = new LiferayUserManager();
|
static UserManager um = new LiferayUserManager();
|
||||||
protected static Logger logger = LoggerFactory.getLogger(UserUtil.class);
|
protected static Logger logger = LoggerFactory.getLogger(UserUtil.class);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the user full name.
|
* Gets the user full name.
|
||||||
*
|
*
|
||||||
|
@ -39,22 +37,22 @@ public class UserUtil {
|
||||||
*/
|
*/
|
||||||
public static String getUserFullName(String portalLogin){
|
public static String getUserFullName(String portalLogin){
|
||||||
// return user.getPortalLogin(); //for testing in eclipse
|
// return user.getPortalLogin(); //for testing in eclipse
|
||||||
|
|
||||||
// logger.trace("Finding full name for: "+portalLogin);
|
// logger.trace("Finding full name for: "+portalLogin);
|
||||||
|
|
||||||
if(portalLogin==null)
|
if(portalLogin==null)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
logger.info("Get user full name for: "+portalLogin);
|
logger.info("Get user full name for: "+portalLogin);
|
||||||
logger.info("Into portal: "+WsUtil.isWithinPortal());
|
logger.info("Into portal: "+WsUtil.isWithinPortal());
|
||||||
if ((portalLogin.compareTo(WsUtil.TEST_USER) != 0) && (WsUtil.isWithinPortal())) { //skip test.user
|
if (portalLogin.compareTo(WsUtil.TEST_USER) != 0 && WsUtil.isWithinPortal()) { //skip test.user
|
||||||
|
|
||||||
UserModel curr = null;
|
UserModel curr = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
curr = um.getUserByScreenName(portalLogin);
|
curr = um.getUserByScreenName(portalLogin);
|
||||||
|
|
||||||
} catch (UserManagementSystemException e) {
|
} catch (UserManagementSystemException e) {
|
||||||
logger.error("An error occurred in getUserFullName "+e,e);
|
logger.error("An error occurred in getUserFullName "+e,e);
|
||||||
} catch (UserRetrievalFault e) {
|
} catch (UserRetrievalFault e) {
|
||||||
|
@ -67,24 +65,22 @@ public class UserUtil {
|
||||||
logger.warn("Return portal login "+portalLogin);
|
logger.warn("Return portal login "+portalLogin);
|
||||||
return portalLogin;
|
return portalLogin;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curr != null){
|
if (curr != null){
|
||||||
|
|
||||||
// logger.trace("Return "+curr.getFullname() +" full name for: "+portalLogin);
|
// logger.trace("Return "+curr.getFullname() +" full name for: "+portalLogin);
|
||||||
return curr.getFullname();
|
return curr.getFullname();
|
||||||
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
logger.info("Return "+WsUtil.TEST_USER_FULL_NAME +" full name for: "+portalLogin);
|
logger.info("We are out of portal, returning login portalLogin "+portalLogin+ "as full name");
|
||||||
return WsUtil.TEST_USER_FULL_NAME;
|
return portalLogin;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Return portal login as full name for: "+portalLogin);
|
logger.info("Return portal login as full name for: "+portalLogin);
|
||||||
return portalLogin;
|
return portalLogin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the organization users.
|
* Gets the organization users.
|
||||||
*
|
*
|
||||||
|
@ -116,7 +112,7 @@ public class UserUtil {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the list login by info contact model.
|
* Gets the list login by info contact model.
|
||||||
*
|
*
|
||||||
|
@ -124,16 +120,16 @@ public class UserUtil {
|
||||||
* @return the list login by info contact model
|
* @return the list login by info contact model
|
||||||
*/
|
*/
|
||||||
public static List<String> getListLoginByInfoContactModel(List<InfoContactModel> listContacts){
|
public static List<String> getListLoginByInfoContactModel(List<InfoContactModel> listContacts){
|
||||||
|
|
||||||
List<String> listUsers = new ArrayList<String>();
|
List<String> listUsers = new ArrayList<String>();
|
||||||
|
|
||||||
for (InfoContactModel infoContactModel : listContacts) {
|
for (InfoContactModel infoContactModel : listContacts) {
|
||||||
listUsers.add(infoContactModel.getLogin());
|
listUsers.add(infoContactModel.getLogin());
|
||||||
}
|
}
|
||||||
|
|
||||||
return listUsers;
|
return listUsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Separate users names to comma.
|
* Separate users names to comma.
|
||||||
*
|
*
|
||||||
|
@ -141,20 +137,20 @@ public class UserUtil {
|
||||||
* @return the string
|
* @return the string
|
||||||
*/
|
*/
|
||||||
public static String separateUsersNamesToComma(List<InfoContactModel> listContacts){
|
public static String separateUsersNamesToComma(List<InfoContactModel> listContacts){
|
||||||
|
|
||||||
String users = "";
|
String users = "";
|
||||||
|
|
||||||
for (int i = 0; i < listContacts.size()-1; i++) {
|
for (int i = 0; i < listContacts.size()-1; i++) {
|
||||||
users+= listContacts.get(i).getName() + ", ";
|
users+= listContacts.get(i).getName() + ", ";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(listContacts.size()>1)
|
if(listContacts.size()>1)
|
||||||
users += listContacts.get(listContacts.size()-1).getName();
|
users += listContacts.get(listContacts.size()-1).getName();
|
||||||
|
|
||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Separate full name to comma for portal login.
|
* Separate full name to comma for portal login.
|
||||||
*
|
*
|
||||||
|
@ -162,17 +158,17 @@ public class UserUtil {
|
||||||
* @return the string
|
* @return the string
|
||||||
*/
|
*/
|
||||||
public static String separateFullNameToCommaForPortalLogin(List<String> listLogin){
|
public static String separateFullNameToCommaForPortalLogin(List<String> listLogin){
|
||||||
|
|
||||||
String users = "";
|
String users = "";
|
||||||
|
|
||||||
for (int i = 0; i < listLogin.size()-1; i++) {
|
for (int i = 0; i < listLogin.size()-1; i++) {
|
||||||
users+= getUserFullName(listLogin.get(i)) + ", ";
|
users+= getUserFullName(listLogin.get(i)) + ", ";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(listLogin.size()>1)
|
if(listLogin.size()>1)
|
||||||
users += getUserFullName(listLogin.get(listLogin.size()-1));
|
users += getUserFullName(listLogin.get(listLogin.size()-1));
|
||||||
|
|
||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.widgets.workspacesharingwidget.server.util;
|
package org.gcube.portlets.widgets.workspacesharingwidget.server.util;
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ import com.liferay.portal.service.UserLocalServiceUtil;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
* @Feb 18, 2014
|
* @Feb 18, 2014
|
||||||
*
|
*
|
||||||
|
@ -45,11 +45,8 @@ public class WsUtil {
|
||||||
public static final String NOTIFICATION_PRODUCER = "NOTIFICATION_SHARING_PRODUCER";
|
public static final String NOTIFICATION_PRODUCER = "NOTIFICATION_SHARING_PRODUCER";
|
||||||
public static final String WORKSPACE_SCOPE_UTIL = "WORKSPACE_SHARING_SCOPE_UTIL";
|
public static final String WORKSPACE_SCOPE_UTIL = "WORKSPACE_SHARING_SCOPE_UTIL";
|
||||||
public static final String NOTIFICATION_PORTLET_CLASS_ID = "org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl"; //USE THE SAME OF WORKSPACE
|
public static final String NOTIFICATION_PORTLET_CLASS_ID = "org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl"; //USE THE SAME OF WORKSPACE
|
||||||
|
|
||||||
|
|
||||||
// public static final String TEST_SCOPE = "/gcube/devsec";
|
// public static final String TEST_SCOPE = "/gcube/devsec";
|
||||||
// public static final String TEST_USER = "pasquale.pagano";
|
// public static final String TEST_USER = "pasquale.pagano";
|
||||||
|
|
||||||
public static final String TEST_SCOPE = "/gcube/devsec";
|
public static final String TEST_SCOPE = "/gcube/devsec";
|
||||||
// public static final String TEST_USER = "federico.defaveri";
|
// public static final String TEST_USER = "federico.defaveri";
|
||||||
// public static final String TEST_USER = "massimiliano.assante";
|
// public static final String TEST_USER = "massimiliano.assante";
|
||||||
|
@ -60,42 +57,38 @@ public class WsUtil {
|
||||||
public static final String TEST_USER = "test.user";
|
public static final String TEST_USER = "test.user";
|
||||||
// public static final String TEST_USER = "antonio.gioia";
|
// public static final String TEST_USER = "antonio.gioia";
|
||||||
public static final String TEST_USER_FULL_NAME = "Test User";
|
public static final String TEST_USER_FULL_NAME = "Test User";
|
||||||
|
|
||||||
|
|
||||||
protected static Logger logger = LoggerFactory.getLogger(WsUtil.class);
|
protected static Logger logger = LoggerFactory.getLogger(WsUtil.class);
|
||||||
|
|
||||||
// public static boolean withoutPortal = false;
|
// public static boolean withoutPortal = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return true if you're running into the portal, false if in development
|
* @return true if you're running into the portal, false if in development
|
||||||
*/
|
*/
|
||||||
public static boolean isWithinPortal() {
|
public static boolean isWithinPortal() {
|
||||||
try {
|
try {
|
||||||
UserLocalServiceUtil.getService();
|
UserLocalServiceUtil.getService();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
logger.info("Development Mode ON");
|
logger.info("Development Mode ON");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ASLSession getAslSession(HttpSession httpSession)
|
public static ASLSession getAslSession(HttpSession httpSession)
|
||||||
{
|
{
|
||||||
String sessionID = httpSession.getId();
|
String sessionID = httpSession.getId();
|
||||||
String user = (String) httpSession.getAttribute(USERNAME_ATTRIBUTE);
|
String user = (String) httpSession.getAttribute(USERNAME_ATTRIBUTE);
|
||||||
ASLSession session;
|
ASLSession session;
|
||||||
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
|
||||||
/*USE ANOTHER ACCOUNT (OTHERWHISE BY TEST_USER) FOR RUNNING
|
/*USE ANOTHER ACCOUNT (OTHERWHISE BY TEST_USER) FOR RUNNING
|
||||||
* COMMENT THIS IN DEVELOP ENVIROMENT (UNCOMMENT IN PRODUCTION)*/
|
* COMMENT THIS IN DEVELOP ENVIROMENT (UNCOMMENT IN PRODUCTION)*/
|
||||||
user=TEST_USER;
|
user=TEST_USER;
|
||||||
|
|
||||||
//UNCOMMENT THIS IN DEVELOP ENVIROMENT
|
//UNCOMMENT THIS IN DEVELOP ENVIROMENT
|
||||||
// user = "francesco.mangiacrapa";
|
// user = "francesco.mangiacrapa";
|
||||||
|
|
||||||
logger.warn("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND - PORTLETS STARTING WITH FOLLOWING SETTINGS:");
|
logger.warn("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND - PORTLETS STARTING WITH FOLLOWING SETTINGS:");
|
||||||
logger.warn("session id: "+sessionID);
|
logger.warn("session id: "+sessionID);
|
||||||
logger.warn("TEST_USER: "+user);
|
logger.warn("TEST_USER: "+user);
|
||||||
|
@ -103,38 +96,30 @@ public class WsUtil {
|
||||||
logger.warn("USERNAME_ATTRIBUTE: "+USERNAME_ATTRIBUTE);
|
logger.warn("USERNAME_ATTRIBUTE: "+USERNAME_ATTRIBUTE);
|
||||||
session = SessionManager.getInstance().getASLSession(sessionID, user);
|
session = SessionManager.getInstance().getASLSession(sessionID, user);
|
||||||
session.setScope(TEST_SCOPE);
|
session.setScope(TEST_SCOPE);
|
||||||
|
|
||||||
//MANDATORY FOR SOCIAL LIBRARY
|
//MANDATORY FOR SOCIAL LIBRARY
|
||||||
session.setUserAvatarId(user + "Avatar");
|
session.setUserAvatarId(user + "Avatar");
|
||||||
session.setUserFullName(TEST_USER_FULL_NAME);
|
session.setUserFullName(TEST_USER_FULL_NAME);
|
||||||
session.setUserEmailAddress(user + "@mail.test");
|
session.setUserEmailAddress(user + "@mail.test");
|
||||||
|
|
||||||
//SET HTTP SESSION ATTRIBUTE
|
//SET HTTP SESSION ATTRIBUTE
|
||||||
httpSession.setAttribute(USERNAME_ATTRIBUTE, user);
|
httpSession.setAttribute(USERNAME_ATTRIBUTE, user);
|
||||||
|
|
||||||
// withoutPortal = true;
|
// withoutPortal = true;
|
||||||
|
|
||||||
return session;
|
return session;
|
||||||
|
|
||||||
}else if(user.compareToIgnoreCase(TEST_USER)==0){
|
}else if(user.compareToIgnoreCase(TEST_USER)==0){
|
||||||
|
|
||||||
// withoutPortal = true;
|
// withoutPortal = true;
|
||||||
|
|
||||||
//COMMENT THIS IN PRODUCTION ENVIROMENT
|
//COMMENT THIS IN PRODUCTION ENVIROMENT
|
||||||
// }else if(user.compareToIgnoreCase("francesco.mangiacrapa")==0){
|
// }else if(user.compareToIgnoreCase("francesco.mangiacrapa")==0){
|
||||||
//
|
|
||||||
// withoutPortal = false;
|
// withoutPortal = false;
|
||||||
// END UNCOMMENT
|
// END UNCOMMENT
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
// withoutPortal = false;
|
// withoutPortal = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SessionManager.getInstance().getASLSession(sessionID, user);
|
return SessionManager.getInstance().getASLSession(sessionID, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param httpSession
|
* @param httpSession
|
||||||
* @return true if current username into ASL session is WsUtil.TEST_USER, false otherwise
|
* @return true if current username into ASL session is WsUtil.TEST_USER, false otherwise
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
@ -144,23 +129,23 @@ public class WsUtil {
|
||||||
//READING USERNAME FROM ASL SESSION
|
//READING USERNAME FROM ASL SESSION
|
||||||
String userUsername = getAslSession(httpSession).getUsername();
|
String userUsername = getAslSession(httpSession).getUsername();
|
||||||
boolean isTestUser = userUsername.compareTo(WsUtil.TEST_USER)==0;
|
boolean isTestUser = userUsername.compareTo(WsUtil.TEST_USER)==0;
|
||||||
|
|
||||||
//TODO UNCOMMENT THIS FOR RELEASE
|
//TODO UNCOMMENT THIS FOR RELEASE
|
||||||
logger.info("Is "+WsUtil.TEST_USER+" test user? "+isTestUser);
|
logger.info("Is "+WsUtil.TEST_USER+" test user? "+isTestUser);
|
||||||
|
|
||||||
if(isTestUser){
|
if(isTestUser){
|
||||||
logger.error("workspace session is expired! username is: "+WsUtil.TEST_USER);
|
logger.error("workspace session is expired! username is: "+WsUtil.TEST_USER);
|
||||||
return true; //is TEST_USER, session is expired
|
return true; //is TEST_USER, session is expired
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("workspace session is valid! current username is: "+userUsername);
|
logger.info("workspace session is valid! current username is: "+userUsername);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param infrastructure the infrastructure name
|
* @param infrastructure the infrastructure name
|
||||||
* @param startScopes the starting scopes
|
* @param startScopes the starting scopes
|
||||||
* @return an arraylist of <class>VO</class> containing their child VREs
|
* @return an arraylist of <class>VO</class> containing their child VREs
|
||||||
|
@ -188,30 +173,30 @@ public class WsUtil {
|
||||||
}
|
}
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Workspace getWorkspace(final HttpSession httpSession) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException
|
public static Workspace getWorkspace(final HttpSession httpSession) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException
|
||||||
{
|
{
|
||||||
|
|
||||||
logger.info("Get Workspace");
|
logger.info("Get Workspace");
|
||||||
final ASLSession session = getAslSession(httpSession);
|
final ASLSession session = getAslSession(httpSession);
|
||||||
logger.info("ASLSession scope: "+session.getScope() + " username: "+session.getUsername());
|
logger.info("ASLSession scope: "+session.getScope() + " username: "+session.getUsername());
|
||||||
|
|
||||||
ScopeProvider.instance.set(session.getScope());
|
ScopeProvider.instance.set(session.getScope());
|
||||||
logger.info("Scope provider instancied");
|
logger.info("Scope provider instancied");
|
||||||
|
|
||||||
Workspace workspace = HomeLibrary.getUserWorkspace(session.getUsername());
|
Workspace workspace = HomeLibrary.getUserWorkspace(session.getUsername());
|
||||||
|
|
||||||
if (session.getAttribute(WORKSPACEBUILDER_ATTRIBUTE) == null)
|
if (session.getAttribute(WORKSPACEBUILDER_ATTRIBUTE) == null)
|
||||||
{
|
{
|
||||||
logger.info("Initializing the workspace area builder");
|
logger.info("Initializing the workspace area builder");
|
||||||
|
|
||||||
GWTWorkspaceSharingBuilder builder = new GWTWorkspaceSharingBuilder();
|
GWTWorkspaceSharingBuilder builder = new GWTWorkspaceSharingBuilder();
|
||||||
|
|
||||||
//ADDED 03/09/2013
|
//ADDED 03/09/2013
|
||||||
//TODO IS GROUP?
|
//TODO IS GROUP?
|
||||||
builder.setUserLogged(new InfoContactModel(session.getUsername(), session.getUsername(), session.getUserFullName(), false));
|
builder.setUserLogged(new InfoContactModel(session.getUsername(), session.getUsername(), session.getUserFullName(), false));
|
||||||
|
|
||||||
session.setAttribute(WORKSPACEBUILDER_ATTRIBUTE, builder);
|
session.setAttribute(WORKSPACEBUILDER_ATTRIBUTE, builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,9 +206,9 @@ public class WsUtil {
|
||||||
|
|
||||||
public static NotificationsManager getNotificationManager(ASLSession session)
|
public static NotificationsManager getNotificationManager(ASLSession session)
|
||||||
{
|
{
|
||||||
|
|
||||||
NotificationsManager notifMng = (NotificationsManager) session.getAttribute(NOTIFICATION_MANAGER);
|
NotificationsManager notifMng = (NotificationsManager) session.getAttribute(NOTIFICATION_MANAGER);
|
||||||
|
|
||||||
if (notifMng == null) {
|
if (notifMng == null) {
|
||||||
try{
|
try{
|
||||||
logger.info("Create new NotificationsManager for user: "+session.getUsername());
|
logger.info("Create new NotificationsManager for user: "+session.getUsername());
|
||||||
|
@ -234,62 +219,62 @@ public class WsUtil {
|
||||||
logger.error("An error occurred instancing ApplicationNotificationsManager for user: "+session.getUsername(),e);
|
logger.error("An error occurred instancing ApplicationNotificationsManager for user: "+session.getUsername(),e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return notifMng;
|
return notifMng;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NotificationsProducer getNotificationProducer(ASLSession session)
|
public static NotificationsProducer getNotificationProducer(ASLSession session)
|
||||||
{
|
{
|
||||||
|
|
||||||
NotificationsProducer notifProducer = (NotificationsProducer) session.getAttribute(NOTIFICATION_PRODUCER);
|
NotificationsProducer notifProducer = (NotificationsProducer) session.getAttribute(NOTIFICATION_PRODUCER);
|
||||||
|
|
||||||
if (notifProducer == null) {
|
if (notifProducer == null) {
|
||||||
logger.info("Create new Notification Producer for user: "+session.getUsername());
|
logger.info("Create new Notification Producer for user: "+session.getUsername());
|
||||||
notifProducer = new NotificationsProducer(session);
|
notifProducer = new NotificationsProducer(session);
|
||||||
session.setAttribute(NOTIFICATION_PRODUCER, notifProducer);
|
session.setAttribute(NOTIFICATION_PRODUCER, notifProducer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return notifProducer;
|
return notifProducer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getUserId(HttpSession httpSession) {
|
public static String getUserId(HttpSession httpSession) {
|
||||||
|
|
||||||
ASLSession session = getAslSession(httpSession);
|
ASLSession session = getAslSession(httpSession);
|
||||||
|
|
||||||
return session.getUsername();
|
return session.getUsername();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isVRE(ASLSession session){
|
public static boolean isVRE(ASLSession session){
|
||||||
|
|
||||||
String currentScope = session.getScopeName();
|
String currentScope = session.getScopeName();
|
||||||
|
|
||||||
int slashCount = StringUtils.countMatches(currentScope, "/");
|
int slashCount = StringUtils.countMatches(currentScope, "/");
|
||||||
|
|
||||||
if(slashCount < 3){
|
if(slashCount < 3){
|
||||||
logger.info("currentScope is not VRE");
|
logger.info("currentScope is not VRE");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("currentScope is VRE");
|
logger.info("currentScope is VRE");
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ScopeUtility getScopeUtilFilter(HttpSession httpSession){
|
public static ScopeUtility getScopeUtilFilter(HttpSession httpSession){
|
||||||
|
|
||||||
ASLSession session = getAslSession(httpSession);
|
ASLSession session = getAslSession(httpSession);
|
||||||
ScopeUtility scopeUtil = null;
|
ScopeUtility scopeUtil = null;
|
||||||
try{
|
try{
|
||||||
scopeUtil = (ScopeUtility) session.getAttribute(WsUtil.WORKSPACE_SCOPE_UTIL);
|
scopeUtil = (ScopeUtility) session.getAttribute(WsUtil.WORKSPACE_SCOPE_UTIL);
|
||||||
|
|
||||||
if(scopeUtil==null){
|
if(scopeUtil==null){
|
||||||
scopeUtil = new ScopeUtility(session.getScopeName());
|
scopeUtil = new ScopeUtility(session.getScopeName());
|
||||||
|
|
||||||
}
|
}
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
logger.error("an error occurred in getscope filter ",e);
|
logger.error("an error occurred in getscope filter ",e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return scopeUtil;
|
return scopeUtil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,16 +285,16 @@ public class WsUtil {
|
||||||
public static GWTWorkspaceSharingBuilder getGWTWorkspaceSharingBuilder(HttpSession httpSession) {
|
public static GWTWorkspaceSharingBuilder getGWTWorkspaceSharingBuilder(HttpSession httpSession) {
|
||||||
ASLSession session = getAslSession(httpSession);
|
ASLSession session = getAslSession(httpSession);
|
||||||
GWTWorkspaceSharingBuilder builder = null;
|
GWTWorkspaceSharingBuilder builder = null;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
builder = (GWTWorkspaceSharingBuilder) session.getAttribute(WsUtil.WORKSPACEBUILDER_ATTRIBUTE);
|
builder = (GWTWorkspaceSharingBuilder) session.getAttribute(WsUtil.WORKSPACEBUILDER_ATTRIBUTE);
|
||||||
|
|
||||||
if(builder==null)
|
if(builder==null)
|
||||||
return new GWTWorkspaceSharingBuilder();
|
return new GWTWorkspaceSharingBuilder();
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
logger.error("an error occurred in get builder ",e);
|
logger.error("an error occurred in get builder ",e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new GWTWorkspaceSharingBuilder();
|
return new GWTWorkspaceSharingBuilder();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,61 +1,141 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.widgets.workspacesharingwidget.shared;
|
package org.gcube.portlets.widgets.workspacesharingwidget.shared;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* The Class CredentialModel.
|
||||||
* @Mar 3, 2014
|
|
||||||
*
|
*
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
* Apr 14, 2016
|
||||||
*/
|
*/
|
||||||
public class CredentialModel implements Serializable{
|
public class CredentialModel implements Serializable{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -4265499048265553603L;
|
private static final long serialVersionUID = 5312392409290548813L;
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private String login;
|
private String login;
|
||||||
private boolean isGroup;
|
private boolean isGroup;
|
||||||
|
private String name;
|
||||||
public CredentialModel(){
|
|
||||||
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @param id
|
* Instantiates a new credential model.
|
||||||
* @param login
|
*/
|
||||||
* @param isGroup
|
public CredentialModel(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new credential model.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @param login the login
|
||||||
|
* @param isGroup the is group
|
||||||
*/
|
*/
|
||||||
public CredentialModel(String id, String login, boolean isGroup) {
|
public CredentialModel(String id, String login, boolean isGroup) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.login = login;
|
this.login = login;
|
||||||
this.isGroup = isGroup;
|
this.isGroup = isGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new credential model.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @param login the login
|
||||||
|
* @param name the name
|
||||||
|
* @param isGroup the is group
|
||||||
|
*/
|
||||||
|
public CredentialModel(String id, String login, String name, boolean isGroup) {
|
||||||
|
this(id,login,isGroup);
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the name.
|
||||||
|
*
|
||||||
|
* @return the name
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the name.
|
||||||
|
*
|
||||||
|
* @param name the name to set
|
||||||
|
*/
|
||||||
|
public void setName(String name) {
|
||||||
|
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the id.
|
||||||
|
*
|
||||||
|
* @return the id
|
||||||
|
*/
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the login.
|
||||||
|
*
|
||||||
|
* @return the login
|
||||||
|
*/
|
||||||
public String getLogin() {
|
public String getLogin() {
|
||||||
return login;
|
return login;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is group.
|
||||||
|
*
|
||||||
|
* @return true, if is group
|
||||||
|
*/
|
||||||
public boolean isGroup() {
|
public boolean isGroup() {
|
||||||
return isGroup;
|
return isGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the id.
|
||||||
|
*
|
||||||
|
* @param id the new id
|
||||||
|
*/
|
||||||
public void setId(String id) {
|
public void setId(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the login.
|
||||||
|
*
|
||||||
|
* @param login the new login
|
||||||
|
*/
|
||||||
public void setLogin(String login) {
|
public void setLogin(String login) {
|
||||||
this.login = login;
|
this.login = login;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the group.
|
||||||
|
*
|
||||||
|
* @param isGroup the new group
|
||||||
|
*/
|
||||||
public void setGroup(boolean isGroup) {
|
public void setGroup(boolean isGroup) {
|
||||||
this.isGroup = isGroup;
|
this.isGroup = isGroup;
|
||||||
}
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#toString()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append("CredentialModel [id=");
|
builder.append("CredentialModel [id=");
|
||||||
builder.append(id);
|
builder.append(id);
|
||||||
|
@ -63,8 +143,9 @@ public class CredentialModel implements Serializable{
|
||||||
builder.append(login);
|
builder.append(login);
|
||||||
builder.append(", isGroup=");
|
builder.append(", isGroup=");
|
||||||
builder.append(isGroup);
|
builder.append(isGroup);
|
||||||
|
builder.append(", name=");
|
||||||
|
builder.append(name);
|
||||||
builder.append("]");
|
builder.append("]");
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue