3892: Workspace Enhancement: use a cache to the list of users during Workspace init
Task-Url: https://support.d4science.org/issues/3892 Updated pom version at 6.11.2 Moved UserStore to get all contacts from DialogShare to ApplicationController in order to load list of users in init phase git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@128471 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
6baae05b1c
commit
4fa170fa62
22
pom.xml
22
pom.xml
|
@ -10,7 +10,7 @@
|
|||
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>workspace-tree-widget</artifactId>
|
||||
<version>6.11.1-SNAPSHOT</version>
|
||||
<version>6.11.2-SNAPSHOT</version>
|
||||
<name>gCube Workspace Tree Widget</name>
|
||||
<description>
|
||||
gCube Workspace Tree Widget is a widget to navigate and interact with gCube Workspace
|
||||
|
@ -37,7 +37,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>maven-portal-bom</artifactId>
|
||||
<version>LATEST</version>
|
||||
<version>2.6.0-SNAPSHOT</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
@ -47,11 +47,11 @@
|
|||
<dependencies>
|
||||
|
||||
<!-- UNCOMMENT THIS TO RUN IN DEVO MODE -->
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>xerces</groupId> -->
|
||||
<!-- <artifactId>xerces</artifactId> -->
|
||||
<!-- <version>2.4.0</version> -->
|
||||
<!-- </dependency> -->
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>xerces</groupId> -->
|
||||
<!-- <artifactId>xerces</artifactId> -->
|
||||
<!-- <version>2.4.0</version> -->
|
||||
<!-- </dependency> -->
|
||||
|
||||
<!-- This dependency is needed to use GWT UI BInder without old Xerces
|
||||
version of gCore complaining -->
|
||||
|
@ -196,13 +196,6 @@
|
|||
<artifactId>xstream</artifactId>
|
||||
<version>1.4.5</version>
|
||||
</dependency>
|
||||
<!-- FILE UPLOAD-progress-bar -->
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>org.gcube.portlets.widgets</groupId> -->
|
||||
<!-- <artifactId>fileupload-progress-bar</artifactId> -->
|
||||
<!-- <version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version> -->
|
||||
<!-- </dependency> -->
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.widgets</groupId>
|
||||
|
@ -242,7 +235,6 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>social-networking-library</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -106,6 +106,7 @@ import org.gcube.portlets.user.workspace.client.util.RequestBuilderWorkspaceVali
|
|||
import org.gcube.portlets.user.workspace.client.util.WindowOpenParameter;
|
||||
import org.gcube.portlets.user.workspace.client.view.ExplorerPanel;
|
||||
import org.gcube.portlets.user.workspace.client.view.sharing.DialogShareFolder;
|
||||
import org.gcube.portlets.user.workspace.client.view.sharing.UserStore;
|
||||
import org.gcube.portlets.user.workspace.client.view.sharing.permissions.DialogPermission;
|
||||
import org.gcube.portlets.user.workspace.client.view.tree.AsyncTreePanel;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.BulkCreatorWindow;
|
||||
|
@ -175,6 +176,8 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
|||
// private FileUploader fileUploader;
|
||||
public static String myLogin;
|
||||
public static String myLoginFirstName;
|
||||
//PRE-LOAD LIST OF USER FORM LIFERAY
|
||||
private UserStore userStore = new UserStore();
|
||||
|
||||
private static AppControllerExplorer singleton;
|
||||
|
||||
|
@ -440,7 +443,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
|||
if(isNewFolder)
|
||||
dialogSharedFolder = new DialogShareFolder(parentDirectoryName,eventBus);
|
||||
else
|
||||
dialogSharedFolder = new DialogShareFolder(parentDirectoryName, sourceFileModel, eventBus);
|
||||
dialogSharedFolder = new DialogShareFolder(parentDirectoryName, sourceFileModel, eventBus, userStore);
|
||||
|
||||
|
||||
final DialogShareFolder finalDialog = dialogSharedFolder;
|
||||
|
@ -1904,6 +1907,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
|||
* @return ExplorerPanel
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public ExplorerPanel getTreePanel(){
|
||||
|
||||
this.explorerPanel = getPanel();
|
||||
|
|
|
@ -41,14 +41,14 @@ import com.google.gwt.user.client.ui.Label;
|
|||
* Nov 4, 2015
|
||||
*/
|
||||
public class DialogShareFolder extends Dialog {
|
||||
|
||||
|
||||
private int widthDialog = 535;
|
||||
private int heightTextArea = 100;
|
||||
private TextField<String> txtName;
|
||||
private TextArea textAreaDescription = new TextArea();
|
||||
private FileModel parentFolder = null;
|
||||
private UserStore userStore = new UserStore();
|
||||
private MultiValuePanel suggestPanel = new MultiValuePanel(userStore);
|
||||
private UserStore userStore;
|
||||
private MultiValuePanel suggestPanel;
|
||||
private Button buttonMultiDrag = new Button("Choose Contacts");
|
||||
private TextField<String> txtOwner;
|
||||
private PanelTogglePermission permission;
|
||||
|
@ -63,14 +63,16 @@ public class DialogShareFolder extends Dialog {
|
|||
* @param folder the folder
|
||||
* @param eventBus the event bus
|
||||
*/
|
||||
public DialogShareFolder(String folderParentName, final FileModel folder, HandlerManager eventBus) {
|
||||
public DialogShareFolder(String folderParentName, final FileModel folder, HandlerManager eventBus, UserStore userStore) {
|
||||
this.userStore = userStore;
|
||||
this.suggestPanel = new MultiValuePanel(userStore);
|
||||
initLayout(folderParentName);
|
||||
this.parentFolder = folder;
|
||||
this.setIcon(Resources.getIconShareFolder());
|
||||
|
||||
setWidth(widthDialog);
|
||||
setButtons(Dialog.OKCANCEL);
|
||||
|
||||
|
||||
setHeading("Share folder: "+folder.getName());
|
||||
|
||||
txtName = new TextField<String>();
|
||||
|
@ -79,7 +81,7 @@ public class DialogShareFolder extends Dialog {
|
|||
txtName.setReadOnly(true);
|
||||
txtName.setAutoValidate(true);
|
||||
txtName.setFieldLabel("Folder Name");
|
||||
|
||||
|
||||
txtOwner = new TextField<String>();
|
||||
txtOwner.setAllowBlank(true);
|
||||
txtOwner.setValue("");
|
||||
|
@ -90,7 +92,7 @@ public class DialogShareFolder extends Dialog {
|
|||
textAreaDescription.setFieldLabel(ConstantsExplorer.DIALOG_DESCRIPTION);
|
||||
textAreaDescription.setHeight(heightTextArea);
|
||||
textAreaDescription.setWidth(380);
|
||||
|
||||
|
||||
textAreaDescription.setValue(folder.getDescription());
|
||||
// textAreaDescription.setReadOnly(true);
|
||||
|
||||
|
@ -109,26 +111,26 @@ public class DialogShareFolder extends Dialog {
|
|||
|
||||
flexTable.setWidget(1, 0, new Label("Add more"));
|
||||
flexTable.setWidget(1, 1, buttonMultiDrag);
|
||||
|
||||
Label labelDescription = new Label("Description");
|
||||
|
||||
Label labelDescription = new Label("Description");
|
||||
flexTable.setWidget(2, 0, labelDescription);
|
||||
flexTable.setWidget(2, 1, textAreaDescription);
|
||||
|
||||
|
||||
hpPermission = new HorizontalPanel();
|
||||
hpPermission.setVerticalAlign(VerticalAlignment.MIDDLE);
|
||||
Label labelProperty = new Label("Permissions");
|
||||
Label labelProperty = new Label("Permissions");
|
||||
hpPermission.add(labelProperty);
|
||||
|
||||
|
||||
AppControllerExplorer.rpcWorkspaceService.getACLs(new AsyncCallback<List<WorkspaceACL>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<WorkspaceACL> result) {
|
||||
permission = new PanelTogglePermission(result);
|
||||
|
||||
|
||||
//ONLY IF FOLDER IS ALREADY SHARED, LOOADING CURRENT ACL FROM HL
|
||||
if(folder.isShared())
|
||||
selectAclForFolder(folder);
|
||||
|
||||
|
||||
hpPermission.add(permission);
|
||||
hpPermission.layout();
|
||||
layout();
|
||||
|
@ -141,12 +143,12 @@ public class DialogShareFolder extends Dialog {
|
|||
layout();
|
||||
}
|
||||
});
|
||||
|
||||
lc.add(flexTable);
|
||||
|
||||
lc.add(flexTable);
|
||||
if(hpPermission!=null)
|
||||
lc.add(hpPermission);
|
||||
lc.mask();
|
||||
|
||||
|
||||
userStore.getOwner(folder.getIdentifier(), new AsyncCallback<InfoContactModel>() {
|
||||
|
||||
@Override
|
||||
|
@ -170,10 +172,10 @@ public class DialogShareFolder extends Dialog {
|
|||
add(lc);
|
||||
addListners();
|
||||
enableFormDialog(false); //FORM IS DISABLED BY DEFAULT
|
||||
|
||||
|
||||
this.show();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update recipient of share.
|
||||
*
|
||||
|
@ -190,7 +192,7 @@ public class DialogShareFolder extends Dialog {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Fill recipient already shared.
|
||||
|
@ -199,28 +201,28 @@ public class DialogShareFolder extends Dialog {
|
|||
* @param lc the lc
|
||||
*/
|
||||
private void fillRecipientAlreadyShared(String folderId, final LayoutContainer lc) {
|
||||
|
||||
|
||||
userStore.getListSharedUserByFolderId(folderId,
|
||||
new AsyncCallback<List<InfoContactModel>>() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<InfoContactModel> listContacts) {
|
||||
|
||||
|
||||
if (listContacts != null) {
|
||||
listAlreadyShared.addAll(listContacts);
|
||||
updateRecipientOfShare(listContacts);
|
||||
}
|
||||
lc.unmask();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
lc.unmask();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Permission control.
|
||||
*
|
||||
|
@ -229,7 +231,7 @@ public class DialogShareFolder extends Dialog {
|
|||
*/
|
||||
private void permissionControl(String owner, boolean showAlert){
|
||||
GWT.log("Permission control compare between owner: "+owner +" and my login: "+AppControllerExplorer.myLogin);
|
||||
|
||||
|
||||
if(AppControllerExplorer.myLogin.compareToIgnoreCase(owner)!=0){
|
||||
enableFormDialog(false);
|
||||
if(showAlert)
|
||||
|
@ -238,7 +240,7 @@ public class DialogShareFolder extends Dialog {
|
|||
enableFormDialog(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enable form dialog.
|
||||
*
|
||||
|
@ -252,7 +254,7 @@ public class DialogShareFolder extends Dialog {
|
|||
permission.setEnabled(bool);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the parent folder.
|
||||
*
|
||||
|
@ -261,7 +263,7 @@ public class DialogShareFolder extends Dialog {
|
|||
public FileModel getParentFolder() {
|
||||
return parentFolder;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Inits the layout.
|
||||
*
|
||||
|
@ -278,7 +280,7 @@ public class DialogShareFolder extends Dialog {
|
|||
setWidth(widthDialog);
|
||||
setHeight(400);
|
||||
setResizable(true);
|
||||
setButtonAlign(HorizontalAlignment.CENTER);
|
||||
setButtonAlign(HorizontalAlignment.CENTER);
|
||||
setWidth(widthDialog);
|
||||
setButtons(Dialog.OKCANCEL);
|
||||
}
|
||||
|
@ -290,7 +292,7 @@ public class DialogShareFolder extends Dialog {
|
|||
* @param eventBus the event bus
|
||||
*/
|
||||
public DialogShareFolder(String folderParentName, HandlerManager eventBus) {
|
||||
|
||||
|
||||
initLayout(folderParentName);
|
||||
this.setIcon(Resources.getIconSharedFolder());
|
||||
setHeading("Create a new shared folder in: "+folderParentName);
|
||||
|
@ -308,7 +310,7 @@ public class DialogShareFolder extends Dialog {
|
|||
textAreaDescription.setFieldLabel(ConstantsExplorer.DIALOG_DESCRIPTION);
|
||||
textAreaDescription.setHeight(heightTextArea);
|
||||
textAreaDescription.setWidth(380);
|
||||
|
||||
|
||||
final LayoutContainer lc = new LayoutContainer();
|
||||
lc.setStyleAttribute("margin-top", "10px");
|
||||
lc.setStyleAttribute("margin-bottom", "10px");
|
||||
|
@ -324,14 +326,14 @@ public class DialogShareFolder extends Dialog {
|
|||
|
||||
flexTable.setWidget(1, 0, new Label("Add more"));
|
||||
flexTable.setWidget(1, 1, buttonMultiDrag);
|
||||
|
||||
Label labelDescription = new Label("Description");
|
||||
|
||||
Label labelDescription = new Label("Description");
|
||||
flexTable.setWidget(2, 0, labelDescription);
|
||||
flexTable.setWidget(2, 1, textAreaDescription);
|
||||
|
||||
|
||||
hpPermission = new HorizontalPanel();
|
||||
hpPermission.setVerticalAlign(VerticalAlignment.MIDDLE);
|
||||
Label labelProperty = new Label("Permissions");
|
||||
Label labelProperty = new Label("Permissions");
|
||||
hpPermission.add(labelProperty);
|
||||
|
||||
AppControllerExplorer.rpcWorkspaceService.getACLs(new AsyncCallback<List<WorkspaceACL>>() {
|
||||
|
@ -352,19 +354,19 @@ public class DialogShareFolder extends Dialog {
|
|||
}
|
||||
});
|
||||
|
||||
lc.add(flexTable);
|
||||
lc.add(flexTable);
|
||||
lc.add(hpPermission);
|
||||
|
||||
|
||||
setFocusWidget(txtName);
|
||||
add(txtName);
|
||||
add(lc);
|
||||
|
||||
addListners();
|
||||
|
||||
|
||||
this.show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the shared list users.
|
||||
*
|
||||
|
@ -380,7 +382,7 @@ public class DialogShareFolder extends Dialog {
|
|||
* Adds the listners.
|
||||
*/
|
||||
public void addListners(){
|
||||
|
||||
|
||||
this.getButtonById(Dialog.CANCEL).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
|
@ -388,8 +390,8 @@ public class DialogShareFolder extends Dialog {
|
|||
hide();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
this.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
|
@ -397,28 +399,28 @@ public class DialogShareFolder extends Dialog {
|
|||
if(isValidForm(false))
|
||||
hide();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
buttonMultiDrag.addClickHandler(new ClickHandler() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
final MultiDragContact multiDrag = new MultiDragContact();
|
||||
multiDrag.show();
|
||||
|
||||
|
||||
List<InfoContactModel> exclusiveContacts = userStore.getExclusiveContactsFromAllContact(suggestPanel.getSelectedUser());
|
||||
multiDrag.addSourceContacts(exclusiveContacts);
|
||||
|
||||
|
||||
for (InfoContactModel infoContactModel : suggestPanel.getSelectedUser()) {
|
||||
// if(!listAlreadyShared.contains(infoContactModel))
|
||||
if(!isShareOwner(infoContactModel))
|
||||
multiDrag.addTargetContact(infoContactModel);
|
||||
}
|
||||
|
||||
|
||||
// multiDrag.addAlreadySharedContacts(suggestPanel.getSelectedUser());
|
||||
|
||||
|
||||
multiDrag.addAlreadySharedContacts(listAlreadyShared);
|
||||
|
||||
|
||||
multiDrag.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
|
@ -428,7 +430,7 @@ public class DialogShareFolder extends Dialog {
|
|||
suggestPanel.addRecipient(shareOwner.getName(),false);
|
||||
for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
|
||||
suggestPanel.addRecipient(infoContactModel.getName(),true);
|
||||
}
|
||||
}
|
||||
suggestPanel.boxSetFocus();
|
||||
// printSelectedUser();
|
||||
}
|
||||
|
@ -436,8 +438,8 @@ public class DialogShareFolder extends Dialog {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Checks if is share owner.
|
||||
*
|
||||
|
@ -448,11 +450,11 @@ public class DialogShareFolder extends Dialog {
|
|||
|
||||
if(infoContactModel!=null && shareOwner!=null && InfoContactModel.COMPARATORLOGINS.compare(infoContactModel, shareOwner)==0)
|
||||
return true;
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* List already shared contains.
|
||||
*
|
||||
|
@ -460,10 +462,10 @@ public class DialogShareFolder extends Dialog {
|
|||
* @return true, if successful
|
||||
*/
|
||||
private boolean listAlreadySharedContains(InfoContactModel contact){
|
||||
|
||||
|
||||
if(contact==null)
|
||||
return false;
|
||||
|
||||
|
||||
for (InfoContactModel ct : listAlreadyShared) {
|
||||
if(InfoContactModel.COMPARATORLOGINS.compare(ct, contact)==0)
|
||||
// if(ct.getLogin().compareTo(contact.getLogin())==0)
|
||||
|
@ -471,19 +473,19 @@ public class DialogShareFolder extends Dialog {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//DEBUG
|
||||
/**
|
||||
* Prints the selected user.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private void printSelectedUser(){
|
||||
|
||||
|
||||
System.out.println("SELETECTED USERS: ");
|
||||
for (InfoContactModel contact : suggestPanel.getSelectedUser())
|
||||
System.out.println(contact);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Inits the suggest contacts.
|
||||
*/
|
||||
|
@ -511,7 +513,7 @@ public class DialogShareFolder extends Dialog {
|
|||
public String getDescription() {
|
||||
if(textAreaDescription.getValue()==null)
|
||||
return "";
|
||||
|
||||
|
||||
return textAreaDescription.getValue();
|
||||
}
|
||||
|
||||
|
@ -522,25 +524,25 @@ public class DialogShareFolder extends Dialog {
|
|||
* @return true, if is valid form
|
||||
*/
|
||||
public boolean isValidForm(boolean displayAlert){
|
||||
|
||||
|
||||
if(!txtName.isValid()){
|
||||
if(displayAlert)
|
||||
new MessageBoxAlert("Attention", "Name must not be empty", null);
|
||||
txtName.focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(getSharedListUsers().size()==0){
|
||||
if(displayAlert)
|
||||
new MessageBoxAlert("Attention", "You must pick at least one user with which share the folder", null);
|
||||
suggestPanel.boxSetFocus();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the selected acl.
|
||||
*
|
||||
|
@ -551,7 +553,7 @@ public class DialogShareFolder extends Dialog {
|
|||
return permission.getSelectedACL();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Select acl for folder.
|
||||
*
|
||||
|
@ -564,7 +566,7 @@ public class DialogShareFolder extends Dialog {
|
|||
@Override
|
||||
public void onFailure(Throwable arg0) {
|
||||
GWT.log("An error occurred on selecting current ACL "+arg0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -575,7 +577,7 @@ public class DialogShareFolder extends Dialog {
|
|||
layout();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,76 +12,105 @@ import com.google.gwt.core.client.GWT;
|
|||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
/**
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* The Class UserStore.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
*/
|
||||
public class UserStore implements ContactFetcher{
|
||||
|
||||
public static List<InfoContactModel> listAllContact = null;
|
||||
|
||||
// public boolean syncronizeCleanSharedUser = false;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new user store.
|
||||
*/
|
||||
public UserStore() {
|
||||
loadAllUsersFromServer(null);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.user.workspace.client.view.sharing.ContactFetcher#getListContact(com.google.gwt.user.client.rpc.AsyncCallback, boolean)
|
||||
*/
|
||||
@Override
|
||||
public void getListContact(AsyncCallback<List<InfoContactModel>> callback, boolean reloadList){
|
||||
|
||||
|
||||
if(reloadList || listAllContact==null)
|
||||
loadAllUsersFromServer(callback);
|
||||
else
|
||||
callback.onSuccess(listAllContact);
|
||||
callback.onSuccess(listAllContact);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.user.workspace.client.view.sharing.ContactFetcher#getListSharedUserByFolderId(java.lang.String, com.google.gwt.user.client.rpc.AsyncCallback)
|
||||
*/
|
||||
@Override
|
||||
public void getListSharedUserByFolderId(String sharedFolderId, AsyncCallback<List<InfoContactModel>> callback){
|
||||
loadSharedUserBySharedFolderId(sharedFolderId, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all users from server.
|
||||
*
|
||||
* @param callback the callback
|
||||
*/
|
||||
private void loadAllUsersFromServer(final AsyncCallback<List<InfoContactModel>> callback){
|
||||
|
||||
|
||||
listAllContact = new ArrayList<InfoContactModel>();
|
||||
|
||||
|
||||
AppControllerExplorer.rpcWorkspaceService.getAllContacts(new AsyncCallback<List<InfoContactModel>>() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<InfoContactModel> result) {
|
||||
GWT.log("loaded "+result.size() + " contacts from server");
|
||||
listAllContact = result;
|
||||
callback.onSuccess(listAllContact);
|
||||
if(callback!=null)
|
||||
callback.onSuccess(listAllContact);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR +" retrieving user " + ConstantsExplorer.TRY_AGAIN, null);
|
||||
callback.onFailure(caught);
|
||||
if(callback!=null)
|
||||
callback.onFailure(caught);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load shared user by shared folder id.
|
||||
*
|
||||
* @param sharedFolderId the shared folder id
|
||||
* @param callback the callback
|
||||
*/
|
||||
private void loadSharedUserBySharedFolderId(final String sharedFolderId, final AsyncCallback<List<InfoContactModel>> callback){
|
||||
|
||||
|
||||
// comboSharedUsers.mask("Loading users");
|
||||
|
||||
|
||||
AppControllerExplorer.rpcWorkspaceService.getListUserSharedByFolderSharedId(sharedFolderId, new AsyncCallback<List<InfoContactModel>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR +" retrieving user. " + ConstantsExplorer.TRY_AGAIN, null);
|
||||
callback.onFailure(caught);
|
||||
if(callback!=null)
|
||||
callback.onFailure(caught);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<InfoContactModel> result) {
|
||||
GWT.log("loaded "+result.size() + " contacts from server for "+sharedFolderId);
|
||||
callback.onSuccess(result);
|
||||
if(callback!=null)
|
||||
callback.onSuccess(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.user.workspace.client.view.sharing.ContactFetcher#getExclusiveContactsFromAllContact(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public List<InfoContactModel> getExclusiveContactsFromAllContact(List<InfoContactModel> listSharedUser){
|
||||
|
||||
|
||||
List<InfoContactModel> listExclusiveContact = new ArrayList<InfoContactModel>(listAllContact);
|
||||
for (InfoContactModel contact : listSharedUser) {
|
||||
if(listAllContact.contains(contact)){
|
||||
|
@ -92,21 +121,24 @@ public class UserStore implements ContactFetcher{
|
|||
return listExclusiveContact;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.user.workspace.client.view.sharing.ContactFetcher#getOwner(java.lang.String, com.google.gwt.user.client.rpc.AsyncCallback)
|
||||
*/
|
||||
@Override
|
||||
public void getOwner(final String sharedFolderId,final AsyncCallback<InfoContactModel> callback) {
|
||||
|
||||
|
||||
AppControllerExplorer.rpcWorkspaceService.getOwnerByItemId(sharedFolderId, new AsyncCallback<InfoContactModel>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
GWT.log("an error occured in get Owner by Id "+sharedFolderId + " "+caught.getMessage());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(InfoContactModel result) {
|
||||
callback.onSuccess(result);
|
||||
|
||||
if(callback!=null)
|
||||
callback.onSuccess(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1463,7 +1463,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
|
||||
try {
|
||||
|
||||
workspaceLogger.trace("Get all contacts from server...");
|
||||
workspaceLogger.debug("Get all contacts from server...");
|
||||
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
||||
|
||||
org.gcube.common.homelibrary.home.workspace.usermanager.UserManager hlUserManager = HomeLibrary.getHomeManagerFactory().getUserManager();
|
||||
|
@ -1504,6 +1504,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
workspaceLogger.trace("Home Library User Manager getting list Gcube Group");
|
||||
listContactsModel.addAll(builder.buildGXTListContactsModelFromGcubeGroup(hlUserManager.getGroups()));
|
||||
|
||||
workspaceLogger.debug("Returning list of contacts!");
|
||||
return listContactsModel;
|
||||
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.workspace.server.notifications;
|
||||
|
||||
|
@ -27,9 +27,9 @@ import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
|||
public class NotificationsProducer {
|
||||
|
||||
protected ScopeBean scope;
|
||||
|
||||
|
||||
protected static Logger logger = Logger.getLogger(NotificationsProducer.class);
|
||||
|
||||
|
||||
protected NotificationsManager notificationsMng;
|
||||
protected ASLSession aslSession;
|
||||
protected String userId;
|
||||
|
@ -72,7 +72,7 @@ public class NotificationsProducer {
|
|||
public ASLSession getAslSession() {
|
||||
return aslSession;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Runs a new thread to notify the contacts passed in input.
|
||||
|
@ -85,22 +85,22 @@ public class NotificationsProducer {
|
|||
new Thread(){
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
|
||||
logger.trace("Send notifies folder sharing is running...");
|
||||
|
||||
|
||||
for (InfoContactModel infoContactModel : listContacts) {
|
||||
try{
|
||||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
||||
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
||||
|
||||
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
||||
|
||||
logger.debug("Sending notification new share folder "+sharedFolder.getName()+" for user "+infoContactModel.getLogin());
|
||||
|
||||
|
||||
//DEBUG
|
||||
// System.out.println("Sending notification new share folder "+sharedFolder.getName()+" for user "+infoContactModel.getLogin());
|
||||
|
||||
boolean notify = notificationsMng.notifyFolderSharing(infoContactModel.getLogin(), sharedFolder);
|
||||
|
||||
|
||||
|
||||
|
||||
if(!notify)
|
||||
logger.error("An error occured when notify user: "+infoContactModel.getLogin());
|
||||
}
|
||||
|
@ -109,16 +109,16 @@ public class NotificationsProducer {
|
|||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
logger.trace("notifies share folder is completed");
|
||||
}
|
||||
}.start();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Runs a new thread to notify the contacts passed in input.
|
||||
*
|
||||
|
@ -133,34 +133,34 @@ public class NotificationsProducer {
|
|||
new Thread(){
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
|
||||
logger.trace("Send notifies shared folder was renamed is running...");
|
||||
|
||||
|
||||
try {
|
||||
|
||||
|
||||
if(NotificationsUtil.checkIsRootFolderShared(folderItem.getId(), idsharedFolder)){
|
||||
logger.trace("Notification isn't sent because the event is on root shared folder");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
} catch (InternalErrorException e1) {
|
||||
logger.error("An error occurred in checkIsRootFolderShared ", e1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for (InfoContactModel infoContactModel : listSharedContact) {
|
||||
try{
|
||||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
||||
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
||||
|
||||
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
||||
|
||||
logger.trace("Sending notification share folder "+itemOldName+" was renamed as " + itemNewName+ "for user "+infoContactModel.getLogin());
|
||||
|
||||
|
||||
//DEBUG
|
||||
System.out.println("Sending notification share folder "+itemOldName+" was renamed as " + itemNewName+ "for user "+infoContactModel.getLogin());
|
||||
|
||||
boolean notify = notificationsMng.notifyFolderRenaming(infoContactModel.getLogin(), itemOldName, itemNewName, idsharedFolder);
|
||||
|
||||
|
||||
|
||||
|
||||
if(!notify)
|
||||
logger.error("An error occured when notify user: "+infoContactModel.getLogin());
|
||||
}
|
||||
|
@ -169,15 +169,15 @@ public class NotificationsProducer {
|
|||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
logger.trace("notifies share folder was renamed is completed");
|
||||
}
|
||||
}.start();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Runs a new thread to notify the contacts passed in input.
|
||||
*
|
||||
|
@ -191,21 +191,21 @@ public class NotificationsProducer {
|
|||
new Thread(){
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
|
||||
logger.trace("Send notifies shared item was updated is running...");
|
||||
|
||||
|
||||
for (InfoContactModel infoContactModel : listSharedContact) {
|
||||
try{
|
||||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
||||
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
||||
|
||||
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
||||
|
||||
logger.trace("Sending notification to user "+infoContactModel.getLogin() + " updated item "+item.getName());
|
||||
|
||||
|
||||
//DEBUG
|
||||
System.out.println("Sending notification to user "+infoContactModel.getLogin() + " updated item "+item.getName());
|
||||
|
||||
// notificationsMng.notifyItemRenaming(infoContactModel.getLogin(), previousName, item, sharedFolder);
|
||||
|
||||
|
||||
boolean notify = notificationsMng.notifyItemRenaming(infoContactModel.getLogin(), previousName, item, sharedFolder);
|
||||
|
||||
if(!notify)
|
||||
|
@ -216,14 +216,14 @@ public class NotificationsProducer {
|
|||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
logger.trace("notifies shared item was updated is completed");
|
||||
}
|
||||
}.start();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Runs a new thread to notify the updated (add/remove) contacts to sharing
|
||||
|
@ -237,88 +237,88 @@ public class NotificationsProducer {
|
|||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
|
||||
try{
|
||||
|
||||
|
||||
//NEW USER SHARED
|
||||
DifferenceBetweenInfoContactModel diff = new DifferenceBetweenInfoContactModel(listSharingContact, listSharedContact);
|
||||
|
||||
|
||||
List<InfoContactModel> listNewContactsShared = diff.getDifferentsContacts();
|
||||
|
||||
|
||||
logger.info("list new contacts shared: "+listNewContactsShared.size());
|
||||
|
||||
|
||||
if(listNewContactsShared.size()>0){
|
||||
|
||||
|
||||
if(listNewContactsShared.size()==1){ //CASE ONLY ONE CONTACS WAS ADDED
|
||||
|
||||
|
||||
InfoContactModel infoContactModel = listNewContactsShared.get(0);
|
||||
|
||||
|
||||
for (InfoContactModel contact : listSharedContact) { //NOTIFIES ALREADY SHARED CONTACTS THAT A NEW USER WAS ADDED
|
||||
|
||||
|
||||
try{
|
||||
|
||||
|
||||
logger.trace("Sending notification to user "+contact.getLogin()+", added user "+ infoContactModel.getLogin() +" to share folder "+sharedFolder.getName());
|
||||
|
||||
|
||||
//DEBUG
|
||||
// System.out.println("Sending notification added user "+ infoContactModel.getLogin() +" to share folder "+sharedFolder.getName() + " for user "+contact.getLogin());
|
||||
|
||||
|
||||
boolean notify = notificationsMng.notifyFolderAddedUser(contact.getLogin(), sharedFolder, infoContactModel.getLogin());
|
||||
|
||||
|
||||
if(!notify)
|
||||
logger.error("An error occured when notifies user: "+contact.getLogin());
|
||||
|
||||
|
||||
}catch (Exception e) {
|
||||
logger.error("An error occured in notifyFolderAddedUser ", e);
|
||||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
List<InfoContactModel> listCts = new ArrayList<InfoContactModel>();
|
||||
listCts.add(infoContactModel);
|
||||
notifyFolderSharing(listCts, sharedFolder); //NOTIFIER NEW USER OF SHARING FOLDER
|
||||
|
||||
|
||||
}else{ //CASE MORE THEN ONE CONTACT WAS ADDED
|
||||
|
||||
|
||||
List<String> listLogins = UserUtil.getListLoginByInfoContactModel(listNewContactsShared);
|
||||
|
||||
|
||||
for (InfoContactModel contact : listSharedContact) { //NOTIFIES ALREADY SHARED CONTACTS THATH A NEW USER WAS ADDED
|
||||
|
||||
|
||||
try{
|
||||
|
||||
|
||||
logger.trace("Sending notification to user "+contact.getLogin()+", added "+listLogins.size()+" users to share folder "+sharedFolder.getName());
|
||||
|
||||
|
||||
//DEBUG
|
||||
// System.out.println("Sending notification added user "+ infoContactModel.getLogin() +" to share folder "+sharedFolder.getName() + " for user "+contact.getLogin());
|
||||
|
||||
|
||||
boolean notify = notificationsMng.notifyFolderAddedUsers(contact.getLogin(), sharedFolder, listLogins);
|
||||
|
||||
|
||||
if(!notify)
|
||||
logger.error("An error occured when notifies user: "+contact.getLogin());
|
||||
|
||||
|
||||
}catch (Exception e) {
|
||||
logger.error("An error occured in notifyFolderAddedUser ", e);
|
||||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
notifyFolderSharing(listNewContactsShared, sharedFolder); //NOTIFIER NEW USER OF SHARING FOLDER
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//USER REMOVED FROM SHARE
|
||||
DifferenceBetweenInfoContactModel diff2 = new DifferenceBetweenInfoContactModel(listSharedContact, listSharingContact);
|
||||
|
||||
|
||||
List<InfoContactModel> listRemovedUsersFromShare = diff2.getDifferentsContacts();
|
||||
|
||||
|
||||
logger.info("list removed contacts from share: "+listRemovedUsersFromShare.size());
|
||||
|
||||
|
||||
if(listRemovedUsersFromShare.size()>0){
|
||||
|
||||
|
||||
for (InfoContactModel contact : listRemovedUsersFromShare)
|
||||
notifyFolderRemovedUser(contact, sharedFolder);
|
||||
}
|
||||
|
||||
|
||||
}catch (Exception e) {
|
||||
logger.error("An error occured in notifyAddedUserToSharing ", e);
|
||||
// e.printStackTrace();
|
||||
|
@ -326,9 +326,9 @@ public class NotificationsProducer {
|
|||
}
|
||||
|
||||
}.start();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Runs a new thread to notify the contacts passed in input.
|
||||
|
@ -339,26 +339,26 @@ public class NotificationsProducer {
|
|||
*/
|
||||
public void notifyFolderUnSharing(final List<InfoContactModel> listContacts, final String unShareFolderId, final String unSharedFolderName) {
|
||||
|
||||
|
||||
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
|
||||
// printContacts(listContacts);
|
||||
logger.trace("Send notifies folder un share is running...");
|
||||
|
||||
|
||||
for (InfoContactModel infoContactModel : listContacts) {
|
||||
try{
|
||||
|
||||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
||||
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
||||
|
||||
|
||||
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" unshare folder "+unSharedFolderName);
|
||||
|
||||
|
||||
//DEBUG
|
||||
// System.out.println("Sending notification to user "+infoContactModel.getLogin() +" un shared folder "+unSharedFolder.getName());
|
||||
// boolean notify = notificationsMng.notifyFolderRemovedUser(infoContactModel.getLogin(), (WorkspaceSharedFolder) unSharedFolder);
|
||||
|
||||
|
||||
boolean notify = notificationsMng.notifyFolderUnsharing(infoContactModel.getLogin(), unShareFolderId, unSharedFolderName);
|
||||
if(!notify)
|
||||
logger.error("An error occured when notifies user: "+infoContactModel.getLogin());
|
||||
|
@ -368,12 +368,12 @@ public class NotificationsProducer {
|
|||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
logger.trace("notifies of un share notifications is completed");
|
||||
}
|
||||
|
||||
}.start();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -387,31 +387,31 @@ public class NotificationsProducer {
|
|||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
|
||||
logger.trace("Send notifies removed user from shared folder is running...");
|
||||
try{
|
||||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
||||
if(userUnShared.getLogin().compareTo(userId)!=0){
|
||||
|
||||
|
||||
logger.debug("Sending notification to user "+userUnShared.getLogin() +" unshared from folder "+shareFolder.getName());
|
||||
boolean notify = notificationsMng.notifyFolderRemovedUser(userUnShared.getLogin(), (WorkspaceSharedFolder) shareFolder);
|
||||
|
||||
boolean notify = notificationsMng.notifyFolderRemovedUser(userUnShared.getLogin(), shareFolder);
|
||||
|
||||
if(!notify)
|
||||
logger.error("An error occured when notifies user: "+userUnShared.getLogin());
|
||||
}
|
||||
|
||||
|
||||
}catch (Exception e) {
|
||||
logger.error("An error occured in notifyFolderRemovedUser ", e);
|
||||
}
|
||||
|
||||
|
||||
logger.trace("notifies of un unshare user is completed");
|
||||
}
|
||||
|
||||
}.start();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Runs a new thread to notify the contacts passed in input.
|
||||
*
|
||||
|
@ -424,27 +424,24 @@ public class NotificationsProducer {
|
|||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
|
||||
// printContacts(listContacts);
|
||||
logger.trace("Send notifies added item in sharedfolder is running...");
|
||||
|
||||
|
||||
//DEBUG
|
||||
System.out.println("Send notifies added item in sharedfolder is running...");
|
||||
|
||||
|
||||
for (InfoContactModel infoContactModel : listContacts) {
|
||||
try{
|
||||
|
||||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
||||
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
||||
|
||||
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" added item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
|
||||
|
||||
//DEBUG
|
||||
System.out.println("Sending notification to user "+infoContactModel.getLogin() +" added item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
|
||||
|
||||
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
||||
|
||||
logger.info("Sending notification to user "+infoContactModel.getLogin() +" added item [id: "+workspaceItem.getId() +"] name: "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
|
||||
|
||||
//DEBUG
|
||||
// System.out.println("Send notify folder un share user "+infoContactModel.getLogin());
|
||||
|
||||
|
||||
boolean notify = notificationsMng.notifyAddedItem(infoContactModel.getLogin(), workspaceItem, sharedFolder);
|
||||
|
||||
if(!notify){
|
||||
|
@ -458,17 +455,17 @@ public class NotificationsProducer {
|
|||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
logger.trace("notifies of added item in shared folder is completed");
|
||||
|
||||
|
||||
//DEBUG
|
||||
// System.out.println("notifies of added item in shared folder is completed");
|
||||
}
|
||||
|
||||
}.start();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Runs a new thread to notify the contacts passed in input.
|
||||
*
|
||||
|
@ -481,27 +478,27 @@ public class NotificationsProducer {
|
|||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
|
||||
// printContacts(listContacts);
|
||||
logger.trace("Send notifies updated item in shared folder is running...");
|
||||
|
||||
|
||||
//DEBUG
|
||||
// System.out.println("Send notifies updated item in shared folder is running...");
|
||||
|
||||
|
||||
for (InfoContactModel infoContactModel : listContacts) {
|
||||
try{
|
||||
|
||||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
||||
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
||||
|
||||
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
||||
|
||||
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" updated item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
|
||||
|
||||
|
||||
//DEBUG
|
||||
// System.out.println("Sending notification to user "+infoContactModel.getLogin() +" updated item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
|
||||
|
||||
|
||||
//DEBUG
|
||||
// System.out.println("Send notify folder un share user "+infoContactModel.getLogin());
|
||||
|
||||
|
||||
boolean notify = notificationsMng.notifyUpdatedItem(infoContactModel.getLogin(), workspaceItem, sharedFolder);
|
||||
|
||||
if(!notify){
|
||||
|
@ -515,20 +512,20 @@ public class NotificationsProducer {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
logger.trace("notifies of updated item in shared folder is completed");
|
||||
|
||||
|
||||
//DEBUG
|
||||
// System.out.println("notifies of updated item in shared folder is completed");
|
||||
}
|
||||
|
||||
}.start();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Runs a new thread to notify the contacts passed in input.
|
||||
*
|
||||
|
@ -538,38 +535,38 @@ public class NotificationsProducer {
|
|||
*/
|
||||
public void notifyMovedItemToSharing(final List<InfoContactModel> listContacts, final WorkspaceItem workspaceItem, final WorkspaceSharedFolder sharedFolder) {
|
||||
|
||||
|
||||
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
|
||||
logger.trace("Sending notification remove item in shared folder is running...");
|
||||
// printContacts(listContacts);
|
||||
|
||||
|
||||
try {
|
||||
|
||||
|
||||
if(NotificationsUtil.checkIsRootFolderShared(workspaceItem.getId(), sharedFolder.getId())){
|
||||
logger.trace("Notification isn't sent because the event is on root shared folder");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
} catch (InternalErrorException e1) {
|
||||
logger.error("An error occurred in checkIsRootFolderShared ", e1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
logger.trace("Sending notification moved item in shared folder is running...");
|
||||
|
||||
|
||||
// System.out.println("Sending notification moved item in shared folder is running...");
|
||||
|
||||
|
||||
for (InfoContactModel infoContactModel : listContacts) {
|
||||
try{
|
||||
|
||||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
||||
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
||||
|
||||
|
||||
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" moved item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
|
||||
|
||||
|
||||
//DEBUG
|
||||
// System.out.println("Sending notification to user "+infoContactModel.getLogin() +" moved item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
|
||||
|
||||
|
@ -577,7 +574,7 @@ public class NotificationsProducer {
|
|||
|
||||
if(!notify){
|
||||
logger.error("An error occured when notify user: "+infoContactModel.getLogin());
|
||||
|
||||
|
||||
//DEBUG
|
||||
// System.out.println("An error occured when notify user: "+infoContactModel.getLogin());
|
||||
}
|
||||
|
@ -587,20 +584,20 @@ public class NotificationsProducer {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
logger.trace("notifies of moved item in shared folder is completed");
|
||||
|
||||
|
||||
//DEBUG
|
||||
// System.out.println("notifies of moved item in shared folder is completed");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}.start();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Runs a new thread to notify the contacts passed in input.
|
||||
*
|
||||
|
@ -610,35 +607,35 @@ public class NotificationsProducer {
|
|||
*/
|
||||
public void notifyRemovedItemToSharing(final List<InfoContactModel> listContacts, final String itemName, final WorkspaceSharedFolder sharedFolder) {
|
||||
|
||||
|
||||
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
|
||||
logger.trace("Sending notification remove item in shared folder is running...");
|
||||
// printContacts(listContacts);
|
||||
|
||||
|
||||
if(itemName==null || itemName.isEmpty()){
|
||||
logger.trace("Notification isn't sent - itemName is null or empty");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(sharedFolder==null){
|
||||
logger.trace("Notification isn't sent - sharedFolder is null");
|
||||
}
|
||||
|
||||
|
||||
logger.trace("Sending notification removed item in shared folder is running...");
|
||||
|
||||
|
||||
// System.out.println("Sending notification removed item in shared folder is running...");
|
||||
|
||||
|
||||
for (InfoContactModel infoContactModel : listContacts) {
|
||||
try{
|
||||
|
||||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
||||
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
||||
|
||||
|
||||
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" removed item "+itemName+" in shared folder "+sharedFolder.getName());
|
||||
|
||||
|
||||
//DEBUG
|
||||
// System.out.println("Sending notification to user "+infoContactModel.getLogin() +" removed item "+itemName+" in shared folder "+sharedFolder.getName());
|
||||
|
||||
|
@ -646,7 +643,7 @@ public class NotificationsProducer {
|
|||
|
||||
if(!notify){
|
||||
logger.error("An error occured when notify user: "+infoContactModel.getLogin());
|
||||
|
||||
|
||||
//DEBUG
|
||||
// System.out.println("An error occured when notify user: "+infoContactModel.getLogin());
|
||||
}
|
||||
|
@ -656,16 +653,16 @@ public class NotificationsProducer {
|
|||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
logger.trace("notifies of moved item in shared folder is completed");
|
||||
|
||||
|
||||
//DEBUG
|
||||
// System.out.println("notifies of moved item in shared folder is completed");
|
||||
}
|
||||
}.start();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Runs a new thread to notify the contacts passed in input.
|
||||
*
|
||||
|
@ -674,28 +671,28 @@ public class NotificationsProducer {
|
|||
*/
|
||||
public void notifySharedFolderDeleted(final List<InfoContactModel> listContacts, final String folderNameDeleted) {
|
||||
|
||||
|
||||
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
|
||||
// printContacts(listContacts);
|
||||
logger.trace("Send notifies shared folder deleted is running...");
|
||||
|
||||
|
||||
for (InfoContactModel infoContactModel : listContacts) {
|
||||
try{
|
||||
|
||||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
||||
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
||||
|
||||
|
||||
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" deleted shared folder "+folderNameDeleted);
|
||||
|
||||
|
||||
//DEBUG
|
||||
System.out.println("Sending notification to user "+infoContactModel.getLogin() +" deleted shared folder "+folderNameDeleted);
|
||||
|
||||
|
||||
//TODO
|
||||
// boolean notify = notificationsMng.
|
||||
|
||||
|
||||
// if(!notify)
|
||||
// logger.error("An error occured when notifies user: "+infoContactModel.getLogin());
|
||||
}
|
||||
|
@ -704,14 +701,14 @@ public class NotificationsProducer {
|
|||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
logger.trace("notifies of deleted shared foder is completed");
|
||||
}
|
||||
|
||||
}.start();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Runs a new thread to notify the contacts passed in input.
|
||||
|
@ -724,14 +721,14 @@ public class NotificationsProducer {
|
|||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
|
||||
// printContacts(listContacts);
|
||||
logger.trace("Send notifies administrator upgrade is running...");
|
||||
if(userToNotify==null || userToNotify.getLogin()==null){
|
||||
logger.warn("Notification abort user to notify is null...");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(sharedFolder==null){
|
||||
logger.warn("Notification abort sharedFolder to notify is null...");
|
||||
return;
|
||||
|
@ -739,21 +736,21 @@ public class NotificationsProducer {
|
|||
try{
|
||||
String login = userToNotify.getLogin();
|
||||
logger.trace("Send notifies administrator upgrade for login: "+login);
|
||||
|
||||
|
||||
boolean notify = notificationsMng.notifyAdministratorUpgrade(login, sharedFolder);
|
||||
logger.trace("Notification sent correctly? "+notify);
|
||||
}catch (Exception e) {
|
||||
logger.error("An error occured in notifyAdministratorUpgrade ", e);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
logger.trace("notifies of administrator upgrade completed");
|
||||
}
|
||||
|
||||
}.start();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Runs a new thread to notify the contacts passed in input.
|
||||
*
|
||||
|
@ -765,14 +762,14 @@ public class NotificationsProducer {
|
|||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
|
||||
// printContacts(listContacts);
|
||||
logger.trace("Send notifies administrator Downgrade is running...");
|
||||
if(userToNotify==null || userToNotify.getLogin()==null){
|
||||
logger.warn("Notification abort user to notify is null...");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(sharedFolder==null){
|
||||
logger.warn("Notification abort sharedFolder to notify is null...");
|
||||
return;
|
||||
|
@ -780,19 +777,19 @@ public class NotificationsProducer {
|
|||
try{
|
||||
String login = userToNotify.getLogin();
|
||||
logger.trace("Send notifies administrator Downgrade for login: "+login);
|
||||
|
||||
|
||||
boolean notify = notificationsMng.notifyAdministratorDowngrade(login, sharedFolder);
|
||||
logger.trace("Notification sent correctly? "+notify);
|
||||
}catch (Exception e) {
|
||||
logger.error("An error occured in notifyAdministratorDowngrade ", e);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
logger.trace("notifies of administrator Downgrade completed");
|
||||
}
|
||||
|
||||
}.start();
|
||||
|
||||
|
||||
}
|
||||
|
||||
//DEBUG
|
||||
|
@ -802,7 +799,7 @@ public class NotificationsProducer {
|
|||
* @param listContacts the list contacts
|
||||
*/
|
||||
private void printContacts(List<InfoContactModel> listContacts){
|
||||
|
||||
|
||||
System.out.println("Print contacts");
|
||||
for (InfoContactModel infoContactModel : listContacts) {
|
||||
System.out.println(infoContactModel);
|
||||
|
@ -822,20 +819,20 @@ public class NotificationsProducer {
|
|||
String user = "francesco.mangiacrapa";
|
||||
String scopeString = "/gcube/devsec/devVRE";
|
||||
String fullName = "Francesco Mangiacrapa";
|
||||
|
||||
|
||||
ScopeBean scope;
|
||||
ASLSession session;
|
||||
|
||||
|
||||
session = SessionManager.getInstance().getASLSession(sessionID, user);
|
||||
scope = new ScopeBean(scopeString);
|
||||
session.setScope(scope.toString());
|
||||
session.setUserAvatarId(user + "Avatar");
|
||||
session.setUserFullName(fullName);
|
||||
|
||||
|
||||
|
||||
|
||||
NotificationsProducer feeder = new NotificationsProducer(session);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.workspace;
|
||||
|
||||
|
@ -18,7 +18,7 @@ import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
|
|||
/**
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* @Jun 18, 2013
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class DonwloadServletTest {
|
||||
|
||||
|
@ -38,37 +38,37 @@ public class DonwloadServletTest {
|
|||
.getHome("francesco.mangiacrapa")
|
||||
.getWorkspace();
|
||||
//
|
||||
|
||||
|
||||
WorkspaceItem root = ws.getRoot();
|
||||
|
||||
|
||||
List<? extends WorkspaceItem> children = root.getChildren();
|
||||
|
||||
|
||||
|
||||
|
||||
for (WorkspaceItem workspaceItem : children) {
|
||||
|
||||
|
||||
if(workspaceItem.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
|
||||
|
||||
|
||||
FolderItem folderItem = (FolderItem) workspaceItem;
|
||||
|
||||
|
||||
if(folderItem.getFolderItemType().equals(FolderItemType.EXTERNAL_FILE)){
|
||||
|
||||
|
||||
ExternalFile f = (ExternalFile) folderItem;
|
||||
|
||||
|
||||
System.out.println("folderItem name: "+f.getName() + ", public link: "+f.getPublicLink());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// WorkspaceItem item = ws.getItem("8ad4e104-0f34-413e-a88c-e754a81104e7");
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// ExternalFile f = (ExternalFile) item;
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// System.out.println("Public link: "+f.getPublicLink());
|
||||
// FileOutputStream out = new FileOutputStream(new File("/tmp/bla"));
|
||||
// // byte[] buffer = new byte[1024];
|
||||
|
@ -77,10 +77,10 @@ public class DonwloadServletTest {
|
|||
// // out.write(buffer, 0, len);
|
||||
// // }
|
||||
//
|
||||
|
||||
|
||||
|
||||
|
||||
// is = f.getData();
|
||||
|
||||
|
||||
|
||||
// IOUtils.copy(is, out);
|
||||
// is.close();
|
||||
|
@ -96,23 +96,23 @@ public class DonwloadServletTest {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void depthVisit(WorkspaceItem item) throws InternalErrorException{
|
||||
|
||||
|
||||
|
||||
if(item.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
|
||||
|
||||
|
||||
WorkspaceFolder folder = (WorkspaceFolder) item;
|
||||
System.out.println("Visit Folder: "+folder.getName());
|
||||
List<? extends WorkspaceItem> children = folder.getChildren();
|
||||
|
||||
|
||||
for (WorkspaceItem workspaceItem : children) {
|
||||
depthVisit(workspaceItem);
|
||||
}
|
||||
}else{
|
||||
|
||||
|
||||
System.out.println("Item name: "+item.getName());
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,9 +31,9 @@ public class ItemRetrieve {
|
|||
|
||||
// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps"; //PRODUCTION
|
||||
public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
||||
public static String TEST_USER = "gianpaolo.coro";
|
||||
public static String TEST_USER = "francesco.mangiacrapa";
|
||||
// public static String ITEMID = "63832213-098d-42d1-8774-89b6349764c0"; //Activity T3.4 working drafts/T2-EC-IMAR-HO-14-015 iMarine Sustainability WP - Business Model tools.pdf
|
||||
public static String ITEMID = "a5aca54d-67cf-4838-9025-9ef5bb204ae9";
|
||||
public static String ITEMID = "ce4866ee-8079-4acf-bcd6-1c9dd786eb73";
|
||||
// d81d3a64-603f-4907-ae74-be8353211807
|
||||
protected static Logger logger = Logger.getLogger(ItemRetrieve.class);
|
||||
|
||||
|
@ -48,14 +48,14 @@ public class ItemRetrieve {
|
|||
Workspace ws = getWorkspace();
|
||||
|
||||
System.out.println(ws.getRoot().getId());
|
||||
// retrieveFirstLevel(ws, null);
|
||||
|
||||
retrieveFirstLevel(ws, ITEMID);
|
||||
|
||||
System.out.println("get workspace -> OK");
|
||||
// WorkspaceItem item = ws.getItem(ITEMID);
|
||||
// System.out.println("get item id: "+item.getId()+", name: "+item.getName() +", parent: "+item.getParent());
|
||||
// System.out.println(item);
|
||||
retrieveFirstLevel(ws, null);
|
||||
//
|
||||
// retrieveFirstLevel(ws, ITEMID);
|
||||
//
|
||||
// System.out.println("get workspace -> OK");
|
||||
WorkspaceItem item = ws.getItem(ITEMID);
|
||||
System.out.println("get item id: "+item.getId()+", name: "+item.getName() +", parent: "+item.getParent().getId() +", parent name: "+item.getParent().getName()+", path :"+item.getPath());
|
||||
System.out.println(item);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -119,50 +119,57 @@ public class ItemRetrieve {
|
|||
int folderItemCounter = 0;
|
||||
int othersCounter = 0;
|
||||
for (WorkspaceItem workspaceItem : children) {
|
||||
try{
|
||||
|
||||
/*if(foundFolder!=null && !foundFolder.isEmpty()){
|
||||
if(workspaceItem.getId().compareTo(foundFolder)==0){
|
||||
System.out.println("ITEM FOUND id: "+workspaceItem.getId()+", name: "+workspaceItem.getName());
|
||||
return;
|
||||
/*if(foundFolder!=null && !foundFolder.isEmpty()){
|
||||
if(workspaceItem.getId().compareTo(foundFolder)==0){
|
||||
System.out.println("ITEM FOUND id: "+workspaceItem.getId()+", name: "+workspaceItem.getName());
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
switch (workspaceItem.getType()) {
|
||||
|
||||
case FOLDER:
|
||||
|
||||
WorkspaceFolder folder = (WorkspaceFolder) workspaceItem;
|
||||
|
||||
// System.out.println(++i+") "+folder.getId() +" folder name: "+folder.getName() + " owner "+folder.getOwner() +" path: "+folder.getPath());
|
||||
System.out.println(++i+") "+folder.getId() +" folder name: "+folder.getName() + " owner "+folder.getOwner());
|
||||
foldersCounter++;
|
||||
|
||||
break;
|
||||
|
||||
case SHARED_FOLDER:
|
||||
|
||||
WorkspaceSharedFolder shared = (WorkspaceSharedFolder) workspaceItem;
|
||||
|
||||
// System.out.println(++i+") "+shared.getId() +" shared folder name: "+shared.getName() + " owner "+shared.getOwner()+" isVRE "+shared.isVreFolder() +" ACLOwner: "+shared.getACLOwner()+" AclUser: "+shared.getACLUser() +" path: "+shared.getPath());
|
||||
System.out.println(++i+") "+shared.getId() +" shared folder name: "+shared.getName());
|
||||
|
||||
// System.out.println(++i+") shared folder name: "+shared.getName() + " owner "+shared.getOwner().getPortalLogin());
|
||||
sharedFoldersCounter++;
|
||||
|
||||
break;
|
||||
|
||||
case FOLDER_ITEM:
|
||||
|
||||
FolderItem folderItem = (FolderItem) workspaceItem;
|
||||
|
||||
// System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", own: "+folderItem.getOwner() +" path: "+folderItem.getPath());
|
||||
System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", own: "+folderItem.getOwner());
|
||||
folderItemCounter++;
|
||||
|
||||
break;
|
||||
default:
|
||||
// System.out.println(++i+") DEFAULT - item id: "+workspaceItem.getId() +", name: "+workspaceItem.getName() + ", own: "+workspaceItem.getOwner());
|
||||
// othersCounter++;
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
switch (workspaceItem.getType()) {
|
||||
|
||||
case FOLDER:
|
||||
|
||||
WorkspaceFolder folder = (WorkspaceFolder) workspaceItem;
|
||||
|
||||
System.out.println(++i+") "+folder.getId() +" folder name: "+folder.getName() + " owner "+folder.getOwner() +" path: "+folder.getPath());
|
||||
foldersCounter++;
|
||||
|
||||
break;
|
||||
|
||||
case SHARED_FOLDER:
|
||||
|
||||
WorkspaceSharedFolder shared = (WorkspaceSharedFolder) workspaceItem;
|
||||
|
||||
System.out.println(++i+") "+shared.getId() +" shared folder name: "+shared.getName() + " owner "+shared.getOwner()+" isVRE "+shared.isVreFolder() +" ACLOwner: "+shared.getACLOwner()+" AclUser: "+shared.getACLUser() +" path: "+shared.getPath());
|
||||
|
||||
// System.out.println(++i+") shared folder name: "+shared.getName() + " owner "+shared.getOwner().getPortalLogin());
|
||||
sharedFoldersCounter++;
|
||||
|
||||
break;
|
||||
|
||||
case FOLDER_ITEM:
|
||||
|
||||
FolderItem folderItem = (FolderItem) workspaceItem;
|
||||
|
||||
System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", own: "+folderItem.getOwner() +" path: "+folderItem.getPath());
|
||||
folderItemCounter++;
|
||||
|
||||
break;
|
||||
default:
|
||||
// System.out.println(++i+") DEFAULT - item id: "+workspaceItem.getId() +", name: "+workspaceItem.getName() + ", own: "+workspaceItem.getOwner());
|
||||
// othersCounter++;
|
||||
break;
|
||||
}catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//TEST TIME
|
||||
|
|
Loading…
Reference in New Issue