updating sharing..
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@69210 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7fa36d874d
commit
b9e0cca41f
|
@ -5,7 +5,7 @@
|
||||||
<inherits name='com.google.gwt.resources.Resources' />
|
<inherits name='com.google.gwt.resources.Resources' />
|
||||||
|
|
||||||
<!-- For development, a default of `DEBUG` is recommended
|
<!-- For development, a default of `DEBUG` is recommended
|
||||||
<inherits name="com.allen_sauer.gwt.log.gwt-log-DEBUG" />-->
|
<inherits name="com.allen_sauer.gwt.log.gwt-log-DEBUG" /> -->
|
||||||
|
|
||||||
<!-- Other module inherits -->
|
<!-- Other module inherits -->
|
||||||
<!-- Moduel GXT -->
|
<!-- Moduel GXT -->
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.gcube.portlets.user.workspace.client;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.portlets.user.workspace.client.event.AddFolderEvent;
|
import org.gcube.portlets.user.workspace.client.event.AddFolderEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.AddFolderEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.AddFolderEventHandler;
|
||||||
|
@ -79,7 +80,6 @@ import org.gcube.portlets.user.workspace.client.interfaces.SubscriberInterface;
|
||||||
import org.gcube.portlets.user.workspace.client.interfaces.TreeAppControllerInterface;
|
import org.gcube.portlets.user.workspace.client.interfaces.TreeAppControllerInterface;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
|
||||||
import org.gcube.portlets.user.workspace.client.model.MessageModel;
|
import org.gcube.portlets.user.workspace.client.model.MessageModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.SmartFolderModel;
|
import org.gcube.portlets.user.workspace.client.model.SmartFolderModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.SubTree;
|
import org.gcube.portlets.user.workspace.client.model.SubTree;
|
||||||
|
@ -129,7 +129,6 @@ import com.google.gwt.user.client.ui.HasWidgets;
|
||||||
*/
|
*/
|
||||||
public class AppControllerExplorer implements EventHandler, TreeAppControllerInterface{
|
public class AppControllerExplorer implements EventHandler, TreeAppControllerInterface{
|
||||||
public static final GWTWorkspaceServiceAsync rpcWorkspaceService = (GWTWorkspaceServiceAsync) GWT.create(GWTWorkspaceService.class);
|
public static final GWTWorkspaceServiceAsync rpcWorkspaceService = (GWTWorkspaceServiceAsync) GWT.create(GWTWorkspaceService.class);
|
||||||
// public static final GWTWorkspaceServiceAsync rpcWorkspaceService = (GWTWorkspaceServiceAsync) Registry.get(ConstantsExplorer.RPC_WORKSPACE_SERVICE);
|
|
||||||
private ExplorerPanel explorerPanel;
|
private ExplorerPanel explorerPanel;
|
||||||
private final static HandlerManager eventBus = new HandlerManager(null);
|
private final static HandlerManager eventBus = new HandlerManager(null);
|
||||||
private HashMap<EventsTypeEnum, ArrayList<SubscriberInterface>> subscribers = null;
|
private HashMap<EventsTypeEnum, ArrayList<SubscriberInterface>> subscribers = null;
|
||||||
|
@ -151,16 +150,10 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
return eventBus;
|
return eventBus;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public WorkspaceFileServiceAsync getRpcService() {
|
|
||||||
// return rpcService;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public GWTWorkspaceServiceAsync getRpcWorkspaceService() {
|
public GWTWorkspaceServiceAsync getRpcWorkspaceService() {
|
||||||
return rpcWorkspaceService;
|
return rpcWorkspaceService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void bind() {
|
private void bind() {
|
||||||
|
|
||||||
eventBus.addHandler(RenderForm.TYPE, new RenderFormEventHandler() {
|
eventBus.addHandler(RenderForm.TYPE, new RenderFormEventHandler() {
|
||||||
|
@ -303,7 +296,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
else{//ITEM IS NOT SHARABLE
|
else{//ITEM IS NOT SHAREABLE
|
||||||
new MessageBoxInfo("Info", "The selected item is not shareable because an ancestor item is already shared");
|
new MessageBoxInfo("Info", "The selected item is not shareable because an ancestor item is already shared");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1290,7 +1283,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
// ArrayList<FileModel> listFileModel = getListParentsByIdentifier(selectedEvent.getFileTarget().getIdentifier());
|
// ArrayList<FileModel> listFileModel = getListParentsByIdentifier(selectedEvent.getFileTarget().getIdentifier());
|
||||||
|
|
||||||
ArrayList<FileModel> listFileModel = new ArrayList<FileModel>();
|
List<FileModel> listFileModel = new ArrayList<FileModel>();
|
||||||
|
|
||||||
FileModel item = explorerPanel.getAsycTreePanel().getFileModelByIdentifier(selectedEvent.getFileTarget().getIdentifier());
|
FileModel item = explorerPanel.getAsycTreePanel().getFileModelByIdentifier(selectedEvent.getFileTarget().getIdentifier());
|
||||||
|
|
||||||
|
@ -1396,7 +1389,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<FileModel> getListParents(ArrayList<FileModel> listParentModel, FileModel item){
|
private List<FileModel> getListParents(List<FileModel> listParentModel, FileModel item){
|
||||||
|
|
||||||
getParents(listParentModel, item);
|
getParents(listParentModel, item);
|
||||||
|
|
||||||
|
@ -1406,7 +1399,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getParents(ArrayList<FileModel> listParents, FileModel item){
|
private void getParents(List<FileModel> listParents, FileModel item){
|
||||||
|
|
||||||
if(item==null || item.getParentFileModel()==null){
|
if(item==null || item.getParentFileModel()==null){
|
||||||
// listParents.add(item);
|
// listParents.add(item);
|
||||||
|
@ -1482,6 +1475,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
this.explorerPanel.getAsycTreePanel().setSizeTreePanel(width, height);
|
this.explorerPanel.getAsycTreePanel().setSizeTreePanel(width, height);
|
||||||
this.explorerPanel.getAsycTreePanel().setHeaderTreeVisible(false);
|
this.explorerPanel.getAsycTreePanel().setHeaderTreeVisible(false);
|
||||||
|
|
||||||
|
|
||||||
return explorerPanel.getAsycTreePanel();
|
return explorerPanel.getAsycTreePanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1588,7 +1582,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<FileModel> pathParentsList = getListParentsByIdentifier(itemIdentifier);
|
ArrayList<FileModel> pathParentsList = (ArrayList<FileModel>) getListParentsByIdentifierFromTree(itemIdentifier);
|
||||||
|
|
||||||
// FileModel fileModel = explorerPanel.getAsycTreePanel().getFileModelByIdentifier(itemIdentifier);
|
// FileModel fileModel = explorerPanel.getAsycTreePanel().getFileModelByIdentifier(itemIdentifier);
|
||||||
// if(fileModel != null && !fileModel.isDirectory())
|
// if(fileModel != null && !fileModel.isDirectory())
|
||||||
|
@ -1622,9 +1616,9 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
//********METHODS TO NOTIFY TREE
|
//********METHODS TO NOTIFY TREE
|
||||||
@Override
|
@Override
|
||||||
public ArrayList<FileModel> getListParentsByIdentifier(String itemIdentifier) {
|
public List<FileModel> getListParentsByIdentifierFromTree(String itemIdentifier) {
|
||||||
|
|
||||||
ArrayList<FileModel> listParentModel = new ArrayList<FileModel>();
|
List<FileModel> listParentModel = new ArrayList<FileModel>();
|
||||||
|
|
||||||
FileModel item = this.explorerPanel.getAsycTreePanel().getFileModelByIdentifier(itemIdentifier);
|
FileModel item = this.explorerPanel.getAsycTreePanel().getFileModelByIdentifier(itemIdentifier);
|
||||||
|
|
||||||
|
@ -1702,8 +1696,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
@Override
|
@Override
|
||||||
public void findItemAndSelectItemInTree(String itemIdentifier) {
|
public void findItemAndSelectItemInTree(String itemIdentifier) {
|
||||||
|
|
||||||
// boolean itemSelected = this.explorerPanel.getAsycTreePanel().selectItem(itemIdentifier);
|
|
||||||
|
|
||||||
FileModel fileModel = this.explorerPanel.getAsycTreePanel().getFileModelByIdentifier(itemIdentifier);
|
FileModel fileModel = this.explorerPanel.getAsycTreePanel().getFileModelByIdentifier(itemIdentifier);
|
||||||
|
|
||||||
if(fileModel==null) { //Loading item by RPC
|
if(fileModel==null) { //Loading item by RPC
|
||||||
|
@ -1714,21 +1706,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
else{
|
else{
|
||||||
|
|
||||||
selectItemInTree(itemIdentifier);
|
selectItemInTree(itemIdentifier);
|
||||||
|
|
||||||
// if(explorerPanel.getAsycTreePanel().isSearch())
|
|
||||||
// deselecteCurrentSelection();
|
|
||||||
//
|
|
||||||
// if(fileModel.isDirectory()){
|
|
||||||
// if(fileModel.getParentFileModel()!=null)
|
|
||||||
// this.explorerPanel.getAsycTreePanel().setExpandTreeLevel(fileModel.getParentFileModel().getIdentifier(), true); //expand parent folder
|
|
||||||
//
|
|
||||||
// this.explorerPanel.getAsycTreePanel().selectItem(itemIdentifier);
|
|
||||||
//
|
|
||||||
//// if(explorerPanel.getAsycTreePanel().isSearch())
|
|
||||||
//// deselecteCurrentSelection();
|
|
||||||
// }else
|
|
||||||
// this.explorerPanel.getAsycTreePanel().selectItem(itemIdentifier); //select item
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.portlets.user.workspace.client.interfaces;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer.ViewSwitchType;
|
import org.gcube.portlets.user.workspace.client.ConstantsExplorer.ViewSwitchType;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||||
|
@ -19,19 +20,16 @@ public interface SubscriberInterface {
|
||||||
// public void deleteItem(FileModel item);
|
// public void deleteItem(FileModel item);
|
||||||
// void addFolder(FolderModel itemFolder);
|
// void addFolder(FolderModel itemFolder);
|
||||||
void addedFile(String itemIdentifier, FileModel parent);
|
void addedFile(String itemIdentifier, FileModel parent);
|
||||||
void selectedItem(FileModel item, ArrayList<FileModel> parents);
|
void selectedItem(FileModel item, List<FileModel> parents);
|
||||||
void expandFolderItem(FolderModel itemFolder);
|
void expandFolderItem(FolderModel itemFolder);
|
||||||
void setParentItemSelected(ArrayList <FileModel> listParents);
|
void setParentItemSelected(ArrayList <FileModel> listParents);
|
||||||
boolean renameItem(String itemIdentifier, String newName, String extension);
|
boolean renameItem(String itemIdentifier, String newName, String extension);
|
||||||
boolean deleteItem(String itemIdentifier);
|
boolean deleteItem(String itemIdentifier);
|
||||||
void addedFolder(String itemIdentifier, FileModel parent);
|
void addedFolder(String itemIdentifier, FileModel parent);
|
||||||
|
|
||||||
void rootLoaded(FileModel root);
|
void rootLoaded(FileModel root);
|
||||||
void smartFolderSelected(String folderId, String category);
|
void smartFolderSelected(String folderId, String category);
|
||||||
void movedItems(String sourceParentIdentifier, FileModel targetParent);
|
void movedItems(String sourceParentIdentifier, FileModel targetParent);
|
||||||
|
|
||||||
void switchView(ViewSwitchType type);
|
void switchView(ViewSwitchType type);
|
||||||
|
|
||||||
void refreshFolder(FileModel fileModel);
|
void refreshFolder(FileModel fileModel);
|
||||||
// void updatePrevieMessage(String fromLogin, String subject, String date, String body, List<FileModel> attachs);
|
// void updatePrevieMessage(String fromLogin, String subject, String date, String body, List<FileModel> attachs);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.gcube.portlets.user.workspace.client.interfaces;
|
package org.gcube.portlets.user.workspace.client.interfaces;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||||
|
|
||||||
|
@ -19,11 +19,8 @@ public interface TreeAppControllerInterface {
|
||||||
boolean addFolder(String itemIdentifier, String name, String parentIdentifier);
|
boolean addFolder(String itemIdentifier, String name, String parentIdentifier);
|
||||||
boolean addFile(String itemIdentifier, String name, String parentIdentifier);
|
boolean addFile(String itemIdentifier, String name, String parentIdentifier);
|
||||||
|
|
||||||
// FileDetailsModel getDetailsOnFileModel(String identifier);
|
|
||||||
|
|
||||||
boolean reloadFolderChildren(String itemIdentifier);
|
boolean reloadFolderChildren(String itemIdentifier);
|
||||||
ArrayList<FileModel> getListParentsByIdentifier(String itemIdentifier);
|
List<FileModel> getListParentsByIdentifierFromTree(String itemIdentifier);
|
||||||
// List<ScopeModel> getAllScope();
|
|
||||||
void setVisualizationType(VisualizationType type);
|
void setVisualizationType(VisualizationType type);
|
||||||
void findItemAndSelectItemInTree(String itemIdentifier);
|
void findItemAndSelectItemInTree(String itemIdentifier);
|
||||||
void expandFolder(String itemIdentifier);
|
void expandFolder(String itemIdentifier);
|
||||||
|
|
|
@ -110,7 +110,7 @@ public interface GWTWorkspaceService extends RemoteService{
|
||||||
|
|
||||||
public boolean unSharedFolderByFolderSharedId(String folderSharedId) throws Exception;
|
public boolean unSharedFolderByFolderSharedId(String folderSharedId) throws Exception;
|
||||||
|
|
||||||
// public ArrayList<String> getListParentsByItemIdentifier(String itemIdentifier) throws Exception;
|
public List<FileModel> getListParentsByItemIdentifier(String itemIdentifier) throws Exception;
|
||||||
|
|
||||||
// public ArrayList<List<FileModel>> getChildrenListsByParentsIdentifier(String itemIdentifier) throws Exception;
|
// public ArrayList<List<FileModel>> getChildrenListsByParentsIdentifier(String itemIdentifier) throws Exception;
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,8 @@ public interface GWTWorkspaceServiceAsync {
|
||||||
void unSharedFolderByFolderSharedId(String folderSharedId,
|
void unSharedFolderByFolderSharedId(String folderSharedId,
|
||||||
AsyncCallback<Boolean> callback);
|
AsyncCallback<Boolean> callback);
|
||||||
|
|
||||||
|
void getListParentsByItemIdentifier(String itemIdentifier,
|
||||||
|
AsyncCallback<List<FileModel>> callback);
|
||||||
|
|
||||||
// void getListParentsByItemIdentifier(String itemIdentifier,AsyncCallback<ArrayList<String>> callback);
|
// void getListParentsByItemIdentifier(String itemIdentifier,AsyncCallback<ArrayList<String>> callback);
|
||||||
|
|
||||||
|
|
|
@ -544,25 +544,21 @@ public class AsyncTreePanel extends LayoutContainer {
|
||||||
else
|
else
|
||||||
type = "null";
|
type = "null";
|
||||||
|
|
||||||
String folderItemType;
|
|
||||||
if(fileModel.getGXTFolderItemType()!=null)
|
|
||||||
folderItemType = fileModel.getGXTFolderItemType().toString();
|
|
||||||
else
|
|
||||||
folderItemType = null;
|
|
||||||
|
|
||||||
//DEBUG
|
//DEBUG
|
||||||
if(fileModel.getParentFileModel()!=null)
|
// String folderItemType;
|
||||||
System.out.println("Item selected " + fileModel.getName() + " Id " + fileModel.getIdentifier() + " Parent " + fileModel.getParentFileModel().getName() + " with id " + fileModel.getParentFileModel().getIdentifier() + " IsDirectory " + ""+fileModel.isDirectory() + " type "+ type + " HLFolderItemType "+folderItemType);
|
// if(fileModel.getGXTFolderItemType()!=null)
|
||||||
else
|
// folderItemType = fileModel.getGXTFolderItemType().toString();
|
||||||
System.out.println("Item selected " + fileModel.getName() + " Id " + fileModel.getIdentifier() + " Parent null " + " IsDirectory " + ""+fileModel.isDirectory()+ " type "+ type +" HLFolderItemType "+folderItemType );
|
// else
|
||||||
|
// folderItemType = null;
|
||||||
|
// if(fileModel.getParentFileModel()!=null)
|
||||||
|
// System.out.println("Item selected " + fileModel.getName() + " Id " + fileModel.getIdentifier() + " Parent " + fileModel.getParentFileModel().getName() + " with id " + fileModel.getParentFileModel().getIdentifier() + " IsDirectory " + ""+fileModel.isDirectory() + " type "+ type + " HLFolderItemType "+folderItemType);
|
||||||
|
// else
|
||||||
|
// System.out.println("Item selected " + fileModel.getName() + " Id " + fileModel.getIdentifier() + " Parent null " + " IsDirectory " + ""+fileModel.isDirectory()+ " type "+ type +" HLFolderItemType "+folderItemType );
|
||||||
|
|
||||||
System.out.println("Item selected" + fileModel);
|
System.out.println("Item selected" + fileModel);
|
||||||
|
|
||||||
eventBus.fireEvent(new SelectedItemEvent(fileModel));
|
eventBus.fireEvent(new SelectedItemEvent(fileModel));
|
||||||
|
|
||||||
// treePanel.findNode(getFileModelByIdentifier(fileModel.getIdentifier()));
|
|
||||||
// cp.setVScrollPosition(treePanel.findNode(objEvent.getSelectedItem().))
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -646,12 +642,6 @@ public class AsyncTreePanel extends LayoutContainer {
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
TreeNode node = be.getNode();
|
TreeNode node = be.getNode();
|
||||||
// FileModel file = treePanel.getSelectionModel().getSelectedItem();
|
|
||||||
//
|
|
||||||
// @SuppressWarnings("rawtypes")
|
|
||||||
// treePanel.TreeNode nodes = (TreeNode) treePanel.getSelectionModel().getSelectedItem();
|
|
||||||
//
|
|
||||||
// be.setItem(treePanel.getSelectionModel().getSelectedItem());
|
|
||||||
|
|
||||||
if(node!=null){
|
if(node!=null){
|
||||||
System.out.println("Menu on: " + node.getModel().get(ConstantsExplorer.NAME));
|
System.out.println("Menu on: " + node.getModel().get(ConstantsExplorer.NAME));
|
||||||
|
@ -665,8 +655,6 @@ public class AsyncTreePanel extends LayoutContainer {
|
||||||
List<FileModel> listSelected = treePanel.getSelectionModel().getSelectedItems();
|
List<FileModel> listSelected = treePanel.getSelectionModel().getSelectedItems();
|
||||||
//
|
//
|
||||||
if (listSelected != null && listSelected.size() > 0) {
|
if (listSelected != null && listSelected.size() > 0) {
|
||||||
|
|
||||||
// FileModel selectedItem = listSelected.get(0); //get first element
|
|
||||||
manageContextMenu();
|
manageContextMenu();
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
@ -741,15 +729,10 @@ public class AsyncTreePanel extends LayoutContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadTreeLevelFromWorkspace(final FolderModel folder){
|
private void loadTreeLevelFromWorkspace(final FolderModel folder){
|
||||||
|
|
||||||
|
|
||||||
System.out.println("Start RPC - getFolderChildren");
|
System.out.println("Start RPC - getFolderChildren");
|
||||||
|
|
||||||
// Log.info("Start RPC - getFolderChildren");
|
// Log.info("Start RPC - getFolderChildren");
|
||||||
|
|
||||||
// final CountTimer count = new CountTimer(1000);
|
// final CountTimer count = new CountTimer(1000);
|
||||||
|
|
||||||
|
|
||||||
AppControllerExplorer.rpcWorkspaceService.getFolderChildren(folder, new AsyncCallback<List<FileModel>>(){
|
AppControllerExplorer.rpcWorkspaceService.getFolderChildren(folder, new AsyncCallback<List<FileModel>>(){
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -761,10 +744,6 @@ public class AsyncTreePanel extends LayoutContainer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<FileModel> result) {
|
public void onSuccess(List<FileModel> result) {
|
||||||
//
|
|
||||||
// be.getTargetEl().setIconStyle("");
|
|
||||||
// be.getNode().getModel().set("icon", Resources.getIconAudio());
|
|
||||||
// be.getNode().getModel().set("overlayIconUrl", Resources.getIconAudio());
|
|
||||||
|
|
||||||
// Log.info("End RPC - getFolderChildren time " + count.getTime());
|
// Log.info("End RPC - getFolderChildren time " + count.getTime());
|
||||||
|
|
||||||
|
@ -952,12 +931,8 @@ public class AsyncTreePanel extends LayoutContainer {
|
||||||
if (record != null) {
|
if (record != null) {
|
||||||
|
|
||||||
FileModel item = (FileModel) record.getModel();
|
FileModel item = (FileModel) record.getModel();
|
||||||
|
|
||||||
// FolderModel parent = (FolderModel) treePanel.getStore().getParent(item);
|
|
||||||
treePanel.getStore().remove(item);
|
treePanel.getStore().remove(item);
|
||||||
|
|
||||||
// treePanel.getStore().getParent((FileModel) record.getModel());
|
|
||||||
// treePanel.getSelectionModel().select(parent, true); //Select the parent of the item deleted
|
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else
|
||||||
System.out.println("Record Error: file target with "
|
System.out.println("Record Error: file target with "
|
||||||
|
|
|
@ -31,25 +31,19 @@ import com.extjs.gxt.ui.client.widget.menu.Menu;
|
||||||
import com.extjs.gxt.ui.client.widget.menu.MenuItem;
|
import com.extjs.gxt.ui.client.widget.menu.MenuItem;
|
||||||
import com.extjs.gxt.ui.client.widget.menu.SeparatorMenuItem;
|
import com.extjs.gxt.ui.client.widget.menu.SeparatorMenuItem;
|
||||||
import com.google.gwt.event.shared.HandlerManager;
|
import com.google.gwt.event.shared.HandlerManager;
|
||||||
import com.google.gwt.user.client.Window;
|
|
||||||
|
|
||||||
public class ContextMenuTree {
|
public class ContextMenuTree {
|
||||||
|
|
||||||
private Menu contextMenu = new Menu();
|
private Menu contextMenu = new Menu();
|
||||||
// private TreePanel<FileModel> treePanel = null;
|
|
||||||
private HandlerManager eventBus = AppControllerExplorer.getEventBus();
|
private HandlerManager eventBus = AppControllerExplorer.getEventBus();
|
||||||
private List<FileModel> listSelectedItems = null;
|
private List<FileModel> listSelectedItems = null;
|
||||||
|
|
||||||
|
|
||||||
public ContextMenuTree() {
|
public ContextMenuTree() {
|
||||||
|
|
||||||
//Context Menu
|
|
||||||
// Menu contextMenu = new Menu();
|
|
||||||
this.contextMenu.setWidth(140);
|
this.contextMenu.setWidth(140);
|
||||||
// this.treePanel = treePanel;
|
|
||||||
this.listSelectedItems = new ArrayList<FileModel>();
|
this.listSelectedItems = new ArrayList<FileModel>();
|
||||||
createContextMenu();
|
createContextMenu();
|
||||||
// return contextMenu;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -88,24 +82,17 @@ public class ContextMenuTree {
|
||||||
openUrl.addSelectionListener(new SelectionListener<MenuEvent>() {
|
openUrl.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
// FileModel selected = treePanel.getSelectionModel().getSelectedItem();
|
|
||||||
|
|
||||||
FileModel selected = listSelectedItems.get(0);
|
FileModel selected = listSelectedItems.get(0);
|
||||||
|
|
||||||
// if(selected!=null)
|
|
||||||
// eventBus.fireEvent(new ImagePreviewEvent(selected, ce.getClientX(), ce.getClientY()));
|
|
||||||
|
|
||||||
if(selected!=null){
|
if(selected!=null){
|
||||||
eventBus.fireEvent(new OpenUrlEvent(selected));
|
eventBus.fireEvent(new OpenUrlEvent(selected));
|
||||||
}
|
}
|
||||||
|
|
||||||
//clearListSelectedItems();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
contextMenu.add(openUrl);
|
contextMenu.add(openUrl);
|
||||||
// contextMenu.add(new SeparatorMenuItem());
|
|
||||||
|
|
||||||
|
|
||||||
//Open Report Template
|
//Open Report Template
|
||||||
|
@ -126,7 +113,6 @@ public class ContextMenuTree {
|
||||||
});
|
});
|
||||||
|
|
||||||
contextMenu.add(openReportTemplate);
|
contextMenu.add(openReportTemplate);
|
||||||
// contextMenu.add(new SeparatorMenuItem());
|
|
||||||
|
|
||||||
|
|
||||||
//Open Report Template
|
//Open Report Template
|
||||||
|
@ -138,20 +124,12 @@ public class ContextMenuTree {
|
||||||
openReport.addSelectionListener(new SelectionListener<MenuEvent>() {
|
openReport.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
// FileModel selected =
|
|
||||||
// treePanel.getSelectionModel().getSelectedItem();
|
|
||||||
|
|
||||||
FileModel selected = listSelectedItems.get(0);
|
FileModel selected = listSelectedItems.get(0);
|
||||||
|
|
||||||
// if(selected!=null)
|
|
||||||
// eventBus.fireEvent(new ImagePreviewEvent(selected,
|
|
||||||
// ce.getClientX(), ce.getClientY()));
|
|
||||||
if (selected != null){
|
if (selected != null){
|
||||||
eventBus.fireEvent(new OpenReportsEvent(selected));
|
eventBus.fireEvent(new OpenReportsEvent(selected));
|
||||||
}
|
}
|
||||||
|
|
||||||
//clearListSelectedItems();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -170,18 +148,12 @@ public class ContextMenuTree {
|
||||||
insertFolder.addSelectionListener(new SelectionListener<MenuEvent>() {
|
insertFolder.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
// final FileModel sourceFileModel = treePanel.getSelectionModel().getSelectedItem();
|
|
||||||
|
|
||||||
final FileModel sourceFileModel = listSelectedItems.get(0);
|
final FileModel sourceFileModel = listSelectedItems.get(0);
|
||||||
|
|
||||||
if (sourceFileModel != null) {
|
if (sourceFileModel != null) {
|
||||||
|
|
||||||
// final FolderModel parentFileModel = (FolderModel) treePanel.getStore().getParent(sourceFileModel); // TODO parent of item
|
|
||||||
|
|
||||||
eventBus.fireEvent(new AddFolderEvent(sourceFileModel, sourceFileModel.getParentFileModel()));
|
eventBus.fireEvent(new AddFolderEvent(sourceFileModel, sourceFileModel.getParentFileModel()));
|
||||||
}
|
}
|
||||||
|
|
||||||
//clearListSelectedItems();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -205,7 +177,6 @@ public class ContextMenuTree {
|
||||||
});
|
});
|
||||||
|
|
||||||
contextMenu.add(createShareFolder);
|
contextMenu.add(createShareFolder);
|
||||||
// contextMenu.add(new SeparatorMenuItem());
|
|
||||||
|
|
||||||
|
|
||||||
//Add Url
|
//Add Url
|
||||||
|
@ -217,7 +188,6 @@ public class ContextMenuTree {
|
||||||
addUrl.addSelectionListener(new SelectionListener<MenuEvent>() {
|
addUrl.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
// FileModel selected = treePanel.getSelectionModel().getSelectedItem();
|
|
||||||
FileModel selected = listSelectedItems.get(0);
|
FileModel selected = listSelectedItems.get(0);
|
||||||
|
|
||||||
FileModel parent = getDirectoryOrParent(selected);
|
FileModel parent = getDirectoryOrParent(selected);
|
||||||
|
@ -226,7 +196,6 @@ public class ContextMenuTree {
|
||||||
eventBus.fireEvent(new CreateUrlEvent(null, parent));
|
eventBus.fireEvent(new CreateUrlEvent(null, parent));
|
||||||
}
|
}
|
||||||
|
|
||||||
//clearListSelectedItems();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -240,13 +209,11 @@ public class ContextMenuTree {
|
||||||
|
|
||||||
copy.addSelectionListener(new SelectionListener<MenuEvent>() {
|
copy.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
// List<FileModel> selected = treePanel.getSelectionModel().getSelectedItems();
|
|
||||||
for (FileModel target : listSelectedItems) {
|
for (FileModel target : listSelectedItems) {
|
||||||
if(target.getIdentifier()!=null){
|
if(target.getIdentifier()!=null){
|
||||||
CopyAndPaste.copy(target.getIdentifier());
|
CopyAndPaste.copy(target.getIdentifier());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//clearListSelectedItems();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -260,30 +227,18 @@ public class ContextMenuTree {
|
||||||
|
|
||||||
paste.addSelectionListener(new SelectionListener<MenuEvent>() {
|
paste.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
// List<FileModel> selected = treePanel.getSelectionModel().getSelectedItems();
|
|
||||||
for (FileModel target : listSelectedItems) {
|
for (FileModel target : listSelectedItems) {
|
||||||
FileModel parentTarget = getDirectoryOrParent(target);
|
FileModel parentTarget = getDirectoryOrParent(target);
|
||||||
if(parentTarget!=null){
|
if(parentTarget!=null){
|
||||||
|
|
||||||
// FileModel source = treePanel.getStore().findModel(ConstantsExplorer.IDENTIFIER, CopyAndPaste.getCopiedfileModelId());
|
eventBus.fireEvent(new PasteItemEvent(CopyAndPaste.getCopiedfileModelId(), parentTarget.getIdentifier()));
|
||||||
//// FileModel parentSource = source.getParentFileModel();
|
CopyAndPaste.setCopiedfileModelId(null);
|
||||||
|
|
||||||
|
|
||||||
// if(parentSource.getIdentifier() != parentTarget.getIdentifier()){
|
|
||||||
|
|
||||||
eventBus.fireEvent(new PasteItemEvent(CopyAndPaste.getCopiedfileModelId(), parentTarget.getIdentifier()));
|
|
||||||
CopyAndPaste.setCopiedfileModelId(null);
|
|
||||||
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// new MessageBoxAlert("Error", "desti", null);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//clearListSelectedItems();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -296,14 +251,12 @@ public class ContextMenuTree {
|
||||||
|
|
||||||
share.addSelectionListener(new SelectionListener<MenuEvent>() {
|
share.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
// List<FileModel> selected = treePanel.getSelectionModel().getSelectedItems();
|
|
||||||
for (FileModel target : listSelectedItems) {
|
for (FileModel target : listSelectedItems) {
|
||||||
|
|
||||||
if(target.getIdentifier()!=null){
|
if(target.getIdentifier()!=null){
|
||||||
eventBus.fireEvent(new CreateSharedFolderEvent(target, target.getParentFileModel(),false));
|
eventBus.fireEvent(new CreateSharedFolderEvent(target, target.getParentFileModel(),false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//clearListSelectedItems();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -317,14 +270,12 @@ public class ContextMenuTree {
|
||||||
|
|
||||||
unShare.addSelectionListener(new SelectionListener<MenuEvent>() {
|
unShare.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
// List<FileModel> selected = treePanel.getSelectionModel().getSelectedItems();
|
|
||||||
for (FileModel target : listSelectedItems) {
|
for (FileModel target : listSelectedItems) {
|
||||||
if(target.getIdentifier()!=null){
|
if(target.getIdentifier()!=null){
|
||||||
eventBus.fireEvent( new UnShareFolderEvent(target));
|
eventBus.fireEvent( new UnShareFolderEvent(target));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//clearListSelectedItems();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -339,15 +290,12 @@ public class ContextMenuTree {
|
||||||
|
|
||||||
rename.addSelectionListener(new SelectionListener<MenuEvent>() {
|
rename.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
// List<FileModel> selected = treePanel.getSelectionModel().getSelectedItems();
|
|
||||||
for (FileModel target : listSelectedItems) {
|
for (FileModel target : listSelectedItems) {
|
||||||
if(target.getIdentifier()!=null){
|
if(target.getIdentifier()!=null){
|
||||||
eventBus.fireEvent(new RenameItemEvent(target));
|
eventBus.fireEvent(new RenameItemEvent(target));
|
||||||
// //clearListSelectedItems();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//clearListSelectedItems();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -361,13 +309,11 @@ public class ContextMenuTree {
|
||||||
|
|
||||||
remove.addSelectionListener(new SelectionListener<MenuEvent>() {
|
remove.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
// List<FileModel> selected = treePanel.getSelectionModel().getSelectedItems();
|
|
||||||
|
|
||||||
for (FileModel sel : listSelectedItems) {
|
for (FileModel sel : listSelectedItems) {
|
||||||
eventBus.fireEvent(new DeleteItemEvent(sel));
|
eventBus.fireEvent(new DeleteItemEvent(sel));
|
||||||
}
|
}
|
||||||
|
|
||||||
//clearListSelectedItems();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -383,7 +329,6 @@ public class ContextMenuTree {
|
||||||
show.addSelectionListener(new SelectionListener<MenuEvent>() {
|
show.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
// List<FileModel> selected = treePanel.getSelectionModel().getSelectedItems();
|
|
||||||
|
|
||||||
for (final FileModel sel : listSelectedItems) {
|
for (final FileModel sel : listSelectedItems) {
|
||||||
eventBus.fireEvent(new FileDownloadEvent(sel.getIdentifier(), sel.getName(), DownloadType.SHOW));
|
eventBus.fireEvent(new FileDownloadEvent(sel.getIdentifier(), sel.getName(), DownloadType.SHOW));
|
||||||
|
@ -404,14 +349,11 @@ public class ContextMenuTree {
|
||||||
viewWebDav.addSelectionListener(new SelectionListener<MenuEvent>() {
|
viewWebDav.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
// List<FileModel> selected = treePanel.getSelectionModel().getSelectedItems();
|
|
||||||
|
|
||||||
for (final FileModel sel : listSelectedItems)
|
for (final FileModel sel : listSelectedItems)
|
||||||
eventBus.fireEvent(new WebDavUrlEvent(sel.getIdentifier()));
|
eventBus.fireEvent(new WebDavUrlEvent(sel.getIdentifier()));
|
||||||
|
|
||||||
|
|
||||||
//clearListSelectedItems();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -427,14 +369,9 @@ public class ContextMenuTree {
|
||||||
sendTo.addSelectionListener(new SelectionListener<MenuEvent>() {
|
sendTo.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
// List<FileModel> selected = treePanel.getSelectionModel().getSelectedItems();
|
|
||||||
|
|
||||||
if(listSelectedItems!=null && listSelectedItems.size()>0)
|
if(listSelectedItems!=null && listSelectedItems.size()>0)
|
||||||
eventBus.fireEvent(new SendMessageEvent(listSelectedItems));
|
eventBus.fireEvent(new SendMessageEvent(listSelectedItems));
|
||||||
|
|
||||||
|
|
||||||
//clearListSelectedItems();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -451,22 +388,13 @@ public class ContextMenuTree {
|
||||||
upload.addSelectionListener(new SelectionListener<MenuEvent>() {
|
upload.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
// List<FileModel> selected = treePanel.getSelectionModel().getSelectedItems();
|
|
||||||
|
|
||||||
for (final FileModel sel : listSelectedItems) {
|
for (final FileModel sel : listSelectedItems) {
|
||||||
|
|
||||||
FileModel parent = getDirectoryOrParent(sel);
|
FileModel parent = getDirectoryOrParent(sel);
|
||||||
|
|
||||||
// if(sel.isDirectory())
|
|
||||||
// parent = sel;
|
|
||||||
// else
|
|
||||||
// parent = sel.getParentFileModel();
|
|
||||||
|
|
||||||
eventBus.fireEvent(new FileUploadEvent(parent, UploadType.FILE));
|
eventBus.fireEvent(new FileUploadEvent(parent, UploadType.FILE));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//clearListSelectedItems();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -482,23 +410,13 @@ public class ContextMenuTree {
|
||||||
uploadArchive.addSelectionListener(new SelectionListener<MenuEvent>() {
|
uploadArchive.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
// List<FileModel> selected = treePanel.getSelectionModel().getSelectedItems();
|
|
||||||
|
|
||||||
for (FileModel sel : listSelectedItems) {
|
for (FileModel sel : listSelectedItems) {
|
||||||
|
|
||||||
FileModel parent = getDirectoryOrParent(sel);
|
FileModel parent = getDirectoryOrParent(sel);
|
||||||
|
|
||||||
// if(sel.isDirectory())
|
|
||||||
// parent = sel;
|
|
||||||
// else
|
|
||||||
// parent = sel.getParentFileModel();
|
|
||||||
|
|
||||||
eventBus.fireEvent(new FileUploadEvent(parent, UploadType.ARCHIVE));
|
eventBus.fireEvent(new FileUploadEvent(parent, UploadType.ARCHIVE));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//clearListSelectedItems();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -513,25 +431,9 @@ public class ContextMenuTree {
|
||||||
downloadArchive.addSelectionListener(new SelectionListener<MenuEvent>() {
|
downloadArchive.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
// List<FileModel> selected = treePanel.getSelectionModel().getSelectedItems();
|
|
||||||
|
|
||||||
for (FileModel sel : listSelectedItems) {
|
for (FileModel sel : listSelectedItems) {
|
||||||
|
|
||||||
// FolderModel parent = null;
|
|
||||||
//
|
|
||||||
// if(sel.isDirectory())
|
|
||||||
// parent = (FolderModel) sel;
|
|
||||||
// else
|
|
||||||
// parent = (FolderModel) store.getParent(sel);
|
|
||||||
|
|
||||||
// Window.alert("Upload nella seguente directory: " + parent.getName());
|
|
||||||
|
|
||||||
eventBus.fireEvent(new FileDownloadEvent(sel.getIdentifier(), sel.getName(), DownloadType.DOWNLOAD));
|
eventBus.fireEvent(new FileDownloadEvent(sel.getIdentifier(), sel.getName(), DownloadType.DOWNLOAD));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//clearListSelectedItems();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -547,13 +449,9 @@ public class ContextMenuTree {
|
||||||
refreshItem.addSelectionListener(new SelectionListener<MenuEvent>() {
|
refreshItem.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
// List<FileModel> selected = treePanel.getSelectionModel().getSelectedItems();
|
|
||||||
|
|
||||||
for (FileModel sel : listSelectedItems) {
|
for (FileModel sel : listSelectedItems) {
|
||||||
eventBus.fireEvent(new RefreshFolderEvent(sel));
|
eventBus.fireEvent(new RefreshFolderEvent(sel));
|
||||||
}
|
}
|
||||||
|
|
||||||
//clearListSelectedItems();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -568,8 +466,6 @@ public class ContextMenuTree {
|
||||||
|
|
||||||
|
|
||||||
public void openContextMenuOnItem(FileModel targetFileModel, int posX, int posY) {
|
public void openContextMenuOnItem(FileModel targetFileModel, int posX, int posY) {
|
||||||
// this.contextMenuPosX = posX;
|
|
||||||
// this.contextMenuPosY = posY;
|
|
||||||
clearListSelectedItems();
|
clearListSelectedItems();
|
||||||
listSelectedItems.add(0, targetFileModel);
|
listSelectedItems.add(0, targetFileModel);
|
||||||
|
|
||||||
|
|
|
@ -1229,6 +1229,13 @@ public class GWTWorkspaceBuilder {
|
||||||
return fileModel;
|
return fileModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param wsFolder
|
||||||
|
* @param parent
|
||||||
|
* @return
|
||||||
|
* @throws InternalErrorException
|
||||||
|
*/
|
||||||
public FolderModel buildGXTFolderModelItem(WorkspaceFolder wsFolder, FileModel parent) throws InternalErrorException {
|
public FolderModel buildGXTFolderModelItem(WorkspaceFolder wsFolder, FileModel parent) throws InternalErrorException {
|
||||||
|
|
||||||
return new FolderModel(wsFolder.getId(),wsFolder.getName(), parent, true, wsFolder.isShared());
|
return new FolderModel(wsFolder.getId(),wsFolder.getName(), parent, true, wsFolder.isShared());
|
||||||
|
@ -1431,11 +1438,11 @@ public class GWTWorkspaceBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
//THIS IS A TEST
|
//THIS IS A TEST
|
||||||
listContactsModel.add(new InfoContactModel("1", "Federico.Test", "Federico de Faveri"));
|
listContactsModel.add(new InfoContactModel("Federico.Test", "Federico.Test", "Federico de Faveri"));
|
||||||
listContactsModel.add(new InfoContactModel("2", "Antonio.Test", "Antonio Gioia"));
|
listContactsModel.add(new InfoContactModel("Antonio.Test", "Antonio.Test", "Antonio Gioia"));
|
||||||
listContactsModel.add(new InfoContactModel("3", "Fabio.Test", "Fabio Sinibaldi"));
|
listContactsModel.add(new InfoContactModel("Fabio.Test", "Fabio.Test", "Fabio Sinibaldi"));
|
||||||
listContactsModel.add(new InfoContactModel("4", Util.TEST_USER, Util.TEST_USER));
|
listContactsModel.add(new InfoContactModel(Util.TEST_USER, Util.TEST_USER, Util.TEST_USER));
|
||||||
listContactsModel.add(new InfoContactModel("5", "Massimiliano.Assante", "Massimiliano Assante"));
|
listContactsModel.add(new InfoContactModel("massimiliano.assante", "massimiliano.assante", "Massimiliano Assante"));
|
||||||
|
|
||||||
return listContactsModel;
|
return listContactsModel;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ import org.gcube.portlets.user.workspace.client.model.SmartFolderModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.SubTree;
|
import org.gcube.portlets.user.workspace.client.model.SubTree;
|
||||||
import org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService;
|
import org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService;
|
||||||
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
|
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
|
||||||
|
import org.gcube.portlets.user.workspace.server.notifications.NotificationsProducer;
|
||||||
import org.gcube.portlets.user.workspace.server.util.AllScope;
|
import org.gcube.portlets.user.workspace.server.util.AllScope;
|
||||||
import org.gcube.portlets.user.workspace.server.util.Util;
|
import org.gcube.portlets.user.workspace.server.util.Util;
|
||||||
|
|
||||||
|
@ -55,7 +56,8 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
public static final String LAST_OPEN_FOLDER_ATTRIBUTE = "WORKSPACE.LAST_OPEN_FOLDER";
|
public static final String LAST_OPEN_FOLDER_ATTRIBUTE = "WORKSPACE.LAST_OPEN_FOLDER";
|
||||||
public static final String SELECTION_STATE_ATTRIBUTE = "WORKSPACE.SELECTION_STATE";
|
public static final String SELECTION_STATE_ATTRIBUTE = "WORKSPACE.SELECTION_STATE";
|
||||||
|
|
||||||
protected GCUBELog workspaceLogger = new GCUBELog("GWTWorkspaceServiceImpl");
|
protected GCUBEClientLog workspaceLogger = new GCUBEClientLog("GWTWorkspaceServiceImpl");
|
||||||
|
|
||||||
|
|
||||||
protected GWTWorkspaceBuilder getGWTWorkspaceBuilder()
|
protected GWTWorkspaceBuilder getGWTWorkspaceBuilder()
|
||||||
{
|
{
|
||||||
|
@ -67,6 +69,15 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
return Util.getWorkspace(this.getThreadLocalRequest().getSession());
|
return Util.getWorkspace(this.getThreadLocalRequest().getSession());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected NotificationsProducer getNotificationProducer(){
|
||||||
|
|
||||||
|
return Util.getNotificationProducer(Util.getAslSession(this.getThreadLocalRequest().getSession()));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getUserId(){
|
||||||
|
return Util.getUserId(this.getThreadLocalRequest().getSession());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FolderModel getRootForTree() throws Exception {
|
public FolderModel getRootForTree() throws Exception {
|
||||||
|
|
||||||
|
@ -638,7 +649,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
return builder.buildGWTWorkspaceImage(item, isInteralImage, fullDetails);
|
return builder.buildGWTWorkspaceImage(item, isInteralImage, fullDetails);
|
||||||
|
|
||||||
// workspaceLogger.trace(" children "+wsFolder.getChildren().size());
|
// workspaceLogger.trace(" children "+wsFolder.getChildren().size());
|
||||||
|
|
||||||
// return builder.buildGWTWorkspaceItemsForGrid(wsFolder.getChildren(), null);
|
// return builder.buildGWTWorkspaceItemsForGrid(wsFolder.getChildren(), null);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -710,11 +720,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
||||||
logger.info("create url in parent id: "+parentFileModel.getIdentifier());
|
logger.info("create url in parent id: "+parentFileModel.getIdentifier());
|
||||||
|
|
||||||
|
//DEBUG
|
||||||
// workspaceLogger.trace("Name " + name);
|
// workspaceLogger.trace("Name " + name);
|
||||||
// workspaceLogger.trace("description " + description);
|
// workspaceLogger.trace("description " + description);
|
||||||
// workspaceLogger.trace("url " + url);
|
// workspaceLogger.trace("url " + url);
|
||||||
// workspaceLogger.trace("parentFileModel " + parentFileModel.getIdentifier() + " " + parentFileModel.getName());
|
// workspaceLogger.trace("parentFileModel " + parentFileModel.getIdentifier() + " " + parentFileModel.getName());
|
||||||
|
|
||||||
// if(description == null)
|
// if(description == null)
|
||||||
// description = "";
|
// description = "";
|
||||||
|
|
||||||
|
@ -1313,6 +1323,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean created = sharedFolder==null?false:true;
|
boolean created = sharedFolder==null?false:true;
|
||||||
|
|
||||||
|
|
||||||
|
if(created){
|
||||||
|
NotificationsProducer np = getNotificationProducer();
|
||||||
|
np.notifyFolderSharing(listContacts, sharedFolder);
|
||||||
|
}
|
||||||
|
|
||||||
return created;
|
return created;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -1344,9 +1361,10 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
return builder.buildGxtInfoContactFromPortalLogin(listUser);
|
return builder.buildGxtInfoContactFromPortalLogin(listUser);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else{
|
||||||
workspaceLogger.trace("the item with id: "+folderSharedId+ "is not "+WorkspaceItemType.SHARED_FOLDER);
|
workspaceLogger.trace("the item with id: "+folderSharedId+ " is not "+WorkspaceItemType.SHARED_FOLDER);
|
||||||
|
System.out.println("the item with id: "+folderSharedId+ " is not "+WorkspaceItemType.SHARED_FOLDER);
|
||||||
|
}
|
||||||
return new ArrayList<InfoContactModel>();
|
return new ArrayList<InfoContactModel>();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -1364,7 +1382,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
try {
|
try {
|
||||||
Workspace workspace = getWorkspace();
|
Workspace workspace = getWorkspace();
|
||||||
|
|
||||||
|
|
||||||
WorkspaceItem wsItem = workspace.getItem(folderSharedId);
|
WorkspaceItem wsItem = workspace.getItem(folderSharedId);
|
||||||
|
|
||||||
if(wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
if(wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
||||||
|
@ -1374,15 +1391,72 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
WorkspaceFolder unSharedFolder = wsFolder.unShare();
|
WorkspaceFolder unSharedFolder = wsFolder.unShare();
|
||||||
|
|
||||||
unShared = unSharedFolder==null?false:true;
|
unShared = unSharedFolder==null?false:true;
|
||||||
|
|
||||||
|
System.out.println("unShared is "+unShared);
|
||||||
|
|
||||||
|
if(unShared){
|
||||||
|
NotificationsProducer np = getNotificationProducer();
|
||||||
|
List<InfoContactModel> contacts = getListUserSharedByFolderSharedId(folderSharedId);
|
||||||
|
|
||||||
|
// //TODO REMOVE THIS
|
||||||
|
contacts = new ArrayList<InfoContactModel>();
|
||||||
|
contacts.add(new InfoContactModel("francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa"));
|
||||||
|
|
||||||
|
|
||||||
|
np.notifyFolderUnSharing(contacts, wsFolder);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
workspaceLogger.trace("the item with id: "+folderSharedId+ "is not "+WorkspaceItemType.SHARED_FOLDER);
|
workspaceLogger.trace("the item with id: "+folderSharedId+ "is not "+WorkspaceItemType.SHARED_FOLDER);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
workspaceLogger.error("Error in unSharedFolderByFolderSharedId ", e);
|
workspaceLogger.error("Error in unSharedFolderByFolderSharedId ", e);
|
||||||
|
e.printStackTrace();
|
||||||
throw new Exception(e.getMessage());
|
throw new Exception(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return unShared;
|
return unShared;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<FileModel> getListParentsByItemIdentifier(String itemIdentifier) throws Exception {
|
||||||
|
List<FileModel> listParents = new ArrayList<FileModel>();
|
||||||
|
workspaceLogger.trace("get List Parents By Item Identifier "+ itemIdentifier);
|
||||||
|
try {
|
||||||
|
Workspace workspace = getWorkspace();
|
||||||
|
|
||||||
|
WorkspaceItem wsItem = workspace.getItem(itemIdentifier);
|
||||||
|
|
||||||
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
||||||
|
|
||||||
|
while(wsItem!=null && wsItem.getParent()!=null){
|
||||||
|
|
||||||
|
WorkspaceFolder wsFolder = wsItem.getParent();
|
||||||
|
listParents.add(builder.buildGXTFolderModelItem(wsFolder, null));
|
||||||
|
wsItem = wsFolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
Collections.reverse(listParents);
|
||||||
|
|
||||||
|
//SET PARENTS
|
||||||
|
for(int i=0; i<listParents.size()-1; i++){
|
||||||
|
|
||||||
|
FileModel parent = listParents.get(i);
|
||||||
|
FileModel fileModel = listParents.get(i+1);
|
||||||
|
|
||||||
|
fileModel.setParentFileModel(parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
workspaceLogger.trace("list parents return size: "+listParents.size());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
workspaceLogger.error("Error in unSharedFolderByFolderSharedId ", e);
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new Exception(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return listParents;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,143 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.workspace.server.notifications;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.gcube.common.core.contexts.GHNContext;
|
||||||
|
import org.gcube.common.core.informationsystem.client.AtomicCondition;
|
||||||
|
import org.gcube.common.core.informationsystem.client.ISClient;
|
||||||
|
import org.gcube.common.core.informationsystem.client.queries.GCUBERIQuery;
|
||||||
|
import org.gcube.common.core.scope.GCUBEScope;
|
||||||
|
|
||||||
|
import com.liferay.portal.model.Organization;
|
||||||
|
import com.liferay.portal.service.OrganizationLocalServiceUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author "Federico De Faveri defaveri@isti.cnr.it"
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class FeedScheduler {
|
||||||
|
|
||||||
|
protected Timer scheduler;
|
||||||
|
protected Map<GCUBEScope, NotificationsProducer> scheduledScopes;
|
||||||
|
protected Logger logger = Logger.getLogger(FeedScheduler.class);
|
||||||
|
|
||||||
|
public FeedScheduler(long refreshTime)
|
||||||
|
{
|
||||||
|
scheduledScopes = new HashMap<GCUBEScope, NotificationsProducer>();
|
||||||
|
scheduler = new Timer(true);
|
||||||
|
scheduler.schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
checkScopes();
|
||||||
|
}
|
||||||
|
}, 0, refreshTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void schedule() throws Exception
|
||||||
|
{
|
||||||
|
List<GCUBEScope> scopes = getAvailableScopes();
|
||||||
|
for (GCUBEScope scope:scopes) {
|
||||||
|
logger.trace("checking scope: "+scope);
|
||||||
|
if (isServicePresentInScope(scope)) {
|
||||||
|
logger.trace("service present");
|
||||||
|
schedule(scope);
|
||||||
|
} else logger.trace("service not present");
|
||||||
|
}
|
||||||
|
|
||||||
|
checkScopes();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void schedule(GCUBEScope scope)
|
||||||
|
{
|
||||||
|
// if (!scheduledScopes.containsKey(scope)) {
|
||||||
|
// NotificationsProducer feeder = new NotificationsProducer(scope);
|
||||||
|
// scheduledScopes.put(scope, feeder);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void checkScopes()
|
||||||
|
{
|
||||||
|
for (NotificationsProducer feeder:scheduledScopes.values()) {
|
||||||
|
try {
|
||||||
|
// feeder.checkOperatorsForFeed();
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isServicePresentInScope(GCUBEScope scope) throws Exception
|
||||||
|
{
|
||||||
|
ISClient isClient = GHNContext.getImplementation(ISClient.class);
|
||||||
|
GCUBERIQuery query = isClient.getQuery(GCUBERIQuery.class);
|
||||||
|
query.addAtomicConditions(new AtomicCondition("/Profile/ServiceName", "statistical-manager-gcubews"));
|
||||||
|
query.addAtomicConditions(new AtomicCondition("/Profile/ServiceClass", "DataAnalysis"));
|
||||||
|
|
||||||
|
return isClient.execute(query, scope).size()>0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static List<GCUBEScope> getAvailableScopes() throws Exception
|
||||||
|
{
|
||||||
|
//FIXME for test only
|
||||||
|
//return Arrays.asList(GCUBEScope.getScope("/gcube/devsec/devVRE"));
|
||||||
|
|
||||||
|
GHNContext ctx = GHNContext.getContext();
|
||||||
|
String rootScopeName = (String) ctx.getProperty(GHNContext.INFRASTRUCTURE_NAME, true);
|
||||||
|
GCUBEScope rootScope = GCUBEScope.getScope("/"+rootScopeName);
|
||||||
|
List<GCUBEScope> scopes = findAvailableScopes(rootScope);
|
||||||
|
return scopes;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static List<GCUBEScope> findAvailableScopes(GCUBEScope infrastructure) throws Exception {
|
||||||
|
|
||||||
|
List<GCUBEScope> scopes = new ArrayList<GCUBEScope>();
|
||||||
|
|
||||||
|
//************* PORTAL MODE, Checking organizations
|
||||||
|
scopes.add(infrastructure);
|
||||||
|
|
||||||
|
///************* GET ROOT ORGANIZATION
|
||||||
|
List<Organization> organizations = OrganizationLocalServiceUtil.getOrganizations(0, OrganizationLocalServiceUtil.getOrganizationsCount());
|
||||||
|
Organization rootOrganization = null;
|
||||||
|
for (Organization organization : organizations) {
|
||||||
|
if (organization.getName().equals(infrastructure.getName()) ) {
|
||||||
|
rootOrganization = organization;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(rootOrganization==null) throw new Exception("Unable to find infrastructure scope "+infrastructure.getName()+" among organizations");
|
||||||
|
//************** GET VO
|
||||||
|
for (Organization vOrg : rootOrganization.getSuborganizations()){
|
||||||
|
String VOScopeString="/"+vOrg.getParentOrganization().getName()+"/"+vOrg.getName();
|
||||||
|
try{
|
||||||
|
scopes.add(GCUBEScope.getScope(VOScopeString));
|
||||||
|
for (Organization vre : vOrg.getSuborganizations()){
|
||||||
|
String VREScopeString=VOScopeString+"/"+vre.getName();
|
||||||
|
try{
|
||||||
|
scopes.add(GCUBEScope.getScope(VREScopeString));
|
||||||
|
}catch(Exception e){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch(Exception e){
|
||||||
|
}
|
||||||
|
//************* GET VRE
|
||||||
|
}
|
||||||
|
|
||||||
|
return scopes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
FeedScheduler scheduler = new FeedScheduler(1000);
|
||||||
|
scheduler.schedule();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,159 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.workspace.server.notifications;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.gcube.application.framework.core.session.ASLSession;
|
||||||
|
import org.gcube.application.framework.core.session.SessionManager;
|
||||||
|
import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
||||||
|
import org.gcube.common.core.scope.GCUBEScope;
|
||||||
|
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceFolder;
|
||||||
|
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
||||||
|
import org.gcube.portlets.user.workspace.server.util.Util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class NotificationsProducer {
|
||||||
|
|
||||||
|
protected Logger logger = Logger.getLogger(NotificationsProducer.class);
|
||||||
|
protected GCUBEScope scope;
|
||||||
|
|
||||||
|
protected NotificationsManager notificationsMng;
|
||||||
|
protected ASLSession aslSession;
|
||||||
|
protected String userId;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param aslSession
|
||||||
|
*/
|
||||||
|
public NotificationsProducer(ASLSession aslSession) {
|
||||||
|
this.notificationsMng = Util.getNotificationManager(aslSession);
|
||||||
|
this.aslSession = aslSession;
|
||||||
|
this.userId = aslSession.getUsername();
|
||||||
|
}
|
||||||
|
|
||||||
|
public NotificationsManager getNotificationsMng() {
|
||||||
|
return notificationsMng;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNotificationMng(NotificationsManager notificationMng) {
|
||||||
|
this.notificationsMng = notificationMng;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ASLSession getAslSession() {
|
||||||
|
return aslSession;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs a new thread to notify the contacts passed in input
|
||||||
|
* @param listContacts
|
||||||
|
* @param sharedFolder
|
||||||
|
*/
|
||||||
|
public void notifyFolderSharing(final List<InfoContactModel> listContacts, final WorkspaceFolder sharedFolder) {
|
||||||
|
|
||||||
|
new Thread(){
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
for (InfoContactModel infoContactModel : listContacts) {
|
||||||
|
try{
|
||||||
|
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
||||||
|
if(infoContactModel.getId().compareTo(userId)!=0){
|
||||||
|
logger.trace("Send notify folder sharing for user "+infoContactModel.getId());
|
||||||
|
boolean notify = notificationsMng.notifyFolderSharing(infoContactModel.getId(), sharedFolder);
|
||||||
|
|
||||||
|
if(!notify)
|
||||||
|
logger.error("An error occured when notify user: "+infoContactModel.getId());
|
||||||
|
}
|
||||||
|
}catch (Exception e) {
|
||||||
|
logger.error("An error occured in notifyFolderSharing ", e);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.trace("share notifications is completed");
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs a new thread to notify the contacts passed in input
|
||||||
|
* @param listContacts
|
||||||
|
* @param sharedFolder
|
||||||
|
*/
|
||||||
|
public void notifyFolderUnSharing(final List<InfoContactModel> listContacts, final WorkspaceFolder sharedFolder) {
|
||||||
|
|
||||||
|
new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
printContacts(listContacts);
|
||||||
|
|
||||||
|
for (InfoContactModel infoContactModel : listContacts) {
|
||||||
|
try{
|
||||||
|
|
||||||
|
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
||||||
|
if(infoContactModel.getId().compareTo(userId)!=0){
|
||||||
|
|
||||||
|
logger.trace("Send notify folder un share user "+infoContactModel.getId());
|
||||||
|
System.out.println("Send notify folder un share user "+infoContactModel.getId());
|
||||||
|
|
||||||
|
boolean notify = notificationsMng.notifyFolderRemovedUser(infoContactModel.getId(), sharedFolder, userId);
|
||||||
|
|
||||||
|
if(!notify)
|
||||||
|
logger.error("An error occured when notify user: "+infoContactModel.getId());
|
||||||
|
}
|
||||||
|
}catch (Exception e) {
|
||||||
|
logger.error("An error occured in notifyFolderSharing ", e);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.trace("un share notifications is completed");
|
||||||
|
System.out.println("un share folder completed");
|
||||||
|
}
|
||||||
|
|
||||||
|
}.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void printContacts(List<InfoContactModel> listContacts){
|
||||||
|
|
||||||
|
System.out.println("Print contacts");
|
||||||
|
for (InfoContactModel infoContactModel : listContacts) {
|
||||||
|
System.out.println(infoContactModel);
|
||||||
|
}
|
||||||
|
System.out.println("End print contacts");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception
|
||||||
|
{
|
||||||
|
String sessionID = "1";
|
||||||
|
String user = "francesco.mangiacrapa";
|
||||||
|
String scopeString = "/gcube/devsec/devVRE";
|
||||||
|
String fullName = "Francesco Mangiacrapa";
|
||||||
|
|
||||||
|
GCUBEScope scope;
|
||||||
|
ASLSession session;
|
||||||
|
|
||||||
|
session = SessionManager.getInstance().getASLSession(sessionID, user);
|
||||||
|
scope = GCUBEScope.getScope(scopeString);
|
||||||
|
session.setScope(scope.toString());
|
||||||
|
session.setUserAvatarId(user + "Avatar");
|
||||||
|
session.setUserFullName(fullName);
|
||||||
|
|
||||||
|
|
||||||
|
NotificationsProducer feeder = new NotificationsProducer(session);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -7,6 +7,8 @@ import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.gcube.application.framework.core.session.ASLSession;
|
import org.gcube.application.framework.core.session.ASLSession;
|
||||||
import org.gcube.application.framework.core.session.SessionManager;
|
import org.gcube.application.framework.core.session.SessionManager;
|
||||||
|
import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager;
|
||||||
|
import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
||||||
import org.gcube.common.core.utils.logging.GCUBEClientLog;
|
import org.gcube.common.core.utils.logging.GCUBEClientLog;
|
||||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||||
import org.gcube.portlets.user.homelibrary.home.HomeLibrary;
|
import org.gcube.portlets.user.homelibrary.home.HomeLibrary;
|
||||||
|
@ -15,6 +17,7 @@ import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorExceptio
|
||||||
import org.gcube.portlets.user.homelibrary.home.workspace.Workspace;
|
import org.gcube.portlets.user.homelibrary.home.workspace.Workspace;
|
||||||
import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
||||||
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
|
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
|
||||||
|
import org.gcube.portlets.user.workspace.server.notifications.NotificationsProducer;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,6 +31,10 @@ public class Util {
|
||||||
public static final String METADATACONVERTER_ATTRIBUTE = "METADATA_CONVERTER";
|
public static final String METADATACONVERTER_ATTRIBUTE = "METADATA_CONVERTER";
|
||||||
public static final String WORKSPACE_EVENT_COLLECTOR_ATTRIBUTE = "EVENT_COLLECTOR";
|
public static final String WORKSPACE_EVENT_COLLECTOR_ATTRIBUTE = "EVENT_COLLECTOR";
|
||||||
public static final String WORKSPACEBUILDER_ATTRIBUTE = "WORKSPACEBUILDER";
|
public static final String WORKSPACEBUILDER_ATTRIBUTE = "WORKSPACEBUILDER";
|
||||||
|
public static final String NOTIFICATION_MANAGER = "NOTIFICATIONMANAGER";
|
||||||
|
public static final String NOTIFICATION_PRODUCER = "NOTIFICATIONMANAGER";
|
||||||
|
|
||||||
|
public static final String NOTIFICATION_PORTLET_CLASS_ID = "org.gcube.portlets.user.wsmail.server.WsMailServiceImpl"; //IN DEV
|
||||||
|
|
||||||
// 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";
|
||||||
|
@ -35,9 +42,9 @@ public class Util {
|
||||||
public static final String TEST_SCOPE = "/gcube/devsec/devVRE";
|
public static final String TEST_SCOPE = "/gcube/devsec/devVRE";
|
||||||
// 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";
|
||||||
public static final String TEST_USER = "francesco.mangiacrapa";
|
|
||||||
|
|
||||||
// public static final String TEST_USER = "pasquale.pagano";
|
// public static final String TEST_USER = "pasquale.pagano";
|
||||||
|
public static final String TEST_USER = "francesco.mangiacrapa";
|
||||||
|
public static final String TEST_USER_FULL_NAME = "Francesco Mangiacrapa";
|
||||||
|
|
||||||
public static GCUBEClientLog defaultLogger = new GCUBEClientLog("WorkspacePortlet");
|
public static GCUBEClientLog defaultLogger = new GCUBEClientLog("WorkspacePortlet");
|
||||||
|
|
||||||
|
@ -54,7 +61,8 @@ public class Util {
|
||||||
httpSession.setAttribute(USERNAME_ATTRIBUTE, TEST_USER);
|
httpSession.setAttribute(USERNAME_ATTRIBUTE, TEST_USER);
|
||||||
ASLSession session = SessionManager.getInstance().getASLSession(sessionID, TEST_USER);
|
ASLSession session = SessionManager.getInstance().getASLSession(sessionID, TEST_USER);
|
||||||
session.setScope(TEST_SCOPE);
|
session.setScope(TEST_SCOPE);
|
||||||
//session.setScope("/d4science.research-infrastructures.eu/Ecosystem/TryIt");
|
session.setUserAvatarId(TEST_USER + "Avatar");
|
||||||
|
session.setUserFullName(TEST_USER_FULL_NAME);
|
||||||
|
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
@ -157,4 +165,39 @@ public class Util {
|
||||||
return (GWTWorkspaceBuilder) session.getAttribute(Util.WORKSPACEBUILDER_ATTRIBUTE);
|
return (GWTWorkspaceBuilder) session.getAttribute(Util.WORKSPACEBUILDER_ATTRIBUTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static NotificationsManager getNotificationManager(ASLSession session)
|
||||||
|
{
|
||||||
|
|
||||||
|
NotificationsManager notifMng = (NotificationsManager) session.getAttribute(NOTIFICATION_MANAGER);
|
||||||
|
|
||||||
|
if (notifMng == null) {
|
||||||
|
defaultLogger.trace("Create new NotificationsManager for user: "+session.getUsername());
|
||||||
|
notifMng = new ApplicationNotificationsManager(session, NOTIFICATION_PORTLET_CLASS_ID);
|
||||||
|
session.setAttribute(NOTIFICATION_MANAGER, notifMng);
|
||||||
|
}
|
||||||
|
|
||||||
|
return notifMng;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NotificationsProducer getNotificationProducer(ASLSession session)
|
||||||
|
{
|
||||||
|
|
||||||
|
NotificationsProducer notifProducer = (NotificationsProducer) session.getAttribute(NOTIFICATION_PRODUCER);
|
||||||
|
|
||||||
|
if (notifProducer == null) {
|
||||||
|
defaultLogger.trace("Create new Notification Producer for user: "+session.getUsername());
|
||||||
|
notifProducer = new NotificationsProducer(session);
|
||||||
|
session.setAttribute(NOTIFICATION_PRODUCER, notifProducer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return notifProducer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getUserId(HttpSession httpSession) {
|
||||||
|
|
||||||
|
ASLSession session = getAslSession(httpSession);
|
||||||
|
|
||||||
|
return session.getUsername();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue