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
task/19600
Francesco Mangiacrapa 11 years ago
parent 7fa36d874d
commit b9e0cca41f

@ -5,7 +5,7 @@
<inherits name='com.google.gwt.resources.Resources' />
<!-- 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 -->
<!-- Moduel GXT -->

@ -3,6 +3,7 @@ package org.gcube.portlets.user.workspace.client;
import java.util.ArrayList;
import java.util.Collections;
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.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.model.FileModel;
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.SmartFolderModel;
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 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 final static HandlerManager eventBus = new HandlerManager(null);
private HashMap<EventsTypeEnum, ArrayList<SubscriberInterface>> subscribers = null;
@ -151,16 +150,10 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
return eventBus;
}
// public WorkspaceFileServiceAsync getRpcService() {
// return rpcService;
// }
public GWTWorkspaceServiceAsync getRpcWorkspaceService() {
return rpcWorkspaceService;
}
private void bind() {
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");
}
@ -1290,7 +1283,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
// 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());
@ -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);
@ -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){
// listParents.add(item);
@ -1482,6 +1475,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
this.explorerPanel.getAsycTreePanel().setSizeTreePanel(width, height);
this.explorerPanel.getAsycTreePanel().setHeaderTreeVisible(false);
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);
// if(fileModel != null && !fileModel.isDirectory())
@ -1622,9 +1616,9 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
//********METHODS TO NOTIFY TREE
@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);
@ -1702,8 +1696,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
@Override
public void findItemAndSelectItemInTree(String itemIdentifier) {
// boolean itemSelected = this.explorerPanel.getAsycTreePanel().selectItem(itemIdentifier);
FileModel fileModel = this.explorerPanel.getAsycTreePanel().getFileModelByIdentifier(itemIdentifier);
if(fileModel==null) { //Loading item by RPC
@ -1714,21 +1706,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
else{
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.HashMap;
import java.util.List;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer.ViewSwitchType;
import org.gcube.portlets.user.workspace.client.model.FileModel;
@ -19,19 +20,16 @@ public interface SubscriberInterface {
// public void deleteItem(FileModel item);
// void addFolder(FolderModel itemFolder);
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 setParentItemSelected(ArrayList <FileModel> listParents);
boolean renameItem(String itemIdentifier, String newName, String extension);
boolean deleteItem(String itemIdentifier);
void addedFolder(String itemIdentifier, FileModel parent);
void rootLoaded(FileModel root);
void smartFolderSelected(String folderId, String category);
void movedItems(String sourceParentIdentifier, FileModel targetParent);
void switchView(ViewSwitchType type);
void refreshFolder(FileModel fileModel);
// 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;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.user.workspace.client.model.FileModel;
@ -18,12 +18,9 @@ public interface TreeAppControllerInterface {
boolean deleteItem(String itemIdentifier);
boolean addFolder(String itemIdentifier, String name, String parentIdentifier);
boolean addFile(String itemIdentifier, String name, String parentIdentifier);
// FileDetailsModel getDetailsOnFileModel(String identifier);
boolean reloadFolderChildren(String itemIdentifier);
ArrayList<FileModel> getListParentsByIdentifier(String itemIdentifier);
// List<ScopeModel> getAllScope();
List<FileModel> getListParentsByIdentifierFromTree(String itemIdentifier);
void setVisualizationType(VisualizationType type);
void findItemAndSelectItemInTree(String itemIdentifier);
void expandFolder(String itemIdentifier);

@ -110,7 +110,7 @@ public interface GWTWorkspaceService extends RemoteService{
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;

@ -113,8 +113,10 @@ public interface GWTWorkspaceServiceAsync {
void unSharedFolderByFolderSharedId(String folderSharedId,
AsyncCallback<Boolean> callback);
void getListParentsByItemIdentifier(String itemIdentifier,
AsyncCallback<List<FileModel>> callback);
// void getListParentsByItemIdentifier(String itemIdentifier,AsyncCallback<ArrayList<String>> callback);
// void getChildrenListsByParentsIdentifier(String itemIdentifier,AsyncCallback<ArrayList<List<FileModel>>> callback);

@ -544,24 +544,20 @@ public class AsyncTreePanel extends LayoutContainer {
else
type = "null";
String folderItemType;
if(fileModel.getGXTFolderItemType()!=null)
folderItemType = fileModel.getGXTFolderItemType().toString();
else
folderItemType = null;
//DEBUG
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 );
// String folderItemType;
// if(fileModel.getGXTFolderItemType()!=null)
// folderItemType = fileModel.getGXTFolderItemType().toString();
// 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);
eventBus.fireEvent(new SelectedItemEvent(fileModel));
// treePanel.findNode(getFileModelByIdentifier(fileModel.getIdentifier()));
// cp.setVScrollPosition(treePanel.findNode(objEvent.getSelectedItem().))
}
@ -646,13 +642,7 @@ public class AsyncTreePanel extends LayoutContainer {
@SuppressWarnings("rawtypes")
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){
System.out.println("Menu on: " + node.getModel().get(ConstantsExplorer.NAME));
System.out.println("node "+ treePanel.findNode(be.getTarget()));
@ -664,9 +654,7 @@ public class AsyncTreePanel extends LayoutContainer {
List<FileModel> listSelected = treePanel.getSelectionModel().getSelectedItems();
//
if (listSelected != null && listSelected.size() > 0) {
// FileModel selectedItem = listSelected.get(0); //get first element
if (listSelected != null && listSelected.size() > 0) {
manageContextMenu();
}
//
@ -741,15 +729,10 @@ public class AsyncTreePanel extends LayoutContainer {
}
private void loadTreeLevelFromWorkspace(final FolderModel folder){
System.out.println("Start RPC - getFolderChildren");
// Log.info("Start RPC - getFolderChildren");
System.out.println("Start RPC - getFolderChildren");
// Log.info("Start RPC - getFolderChildren");
// final CountTimer count = new CountTimer(1000);
AppControllerExplorer.rpcWorkspaceService.getFolderChildren(folder, new AsyncCallback<List<FileModel>>(){
@Override
@ -761,11 +744,7 @@ public class AsyncTreePanel extends LayoutContainer {
@Override
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());
if(treePanel.isMasked())
@ -952,12 +931,8 @@ public class AsyncTreePanel extends LayoutContainer {
if (record != null) {
FileModel item = (FileModel) record.getModel();
// FolderModel parent = (FolderModel) treePanel.getStore().getParent(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;
} else
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.SeparatorMenuItem;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Window;
public class ContextMenuTree {
private Menu contextMenu = new Menu();
// private TreePanel<FileModel> treePanel = null;
private HandlerManager eventBus = AppControllerExplorer.getEventBus();
private List<FileModel> listSelectedItems = null;
public ContextMenuTree() {
//Context Menu
// Menu contextMenu = new Menu();
this.contextMenu.setWidth(140);
// this.treePanel = treePanel;
this.listSelectedItems = new ArrayList<FileModel>();
createContextMenu();
// return contextMenu;
}
@ -87,25 +81,18 @@ public class ContextMenuTree {
openUrl.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) {
// FileModel selected = treePanel.getSelectionModel().getSelectedItem();
FileModel selected = listSelectedItems.get(0);
// if(selected!=null)
// eventBus.fireEvent(new ImagePreviewEvent(selected, ce.getClientX(), ce.getClientY()));
if(selected!=null){
eventBus.fireEvent(new OpenUrlEvent(selected));
}
//clearListSelectedItems();
}
});
contextMenu.add(openUrl);
// contextMenu.add(new SeparatorMenuItem());
//Open Report Template
@ -126,7 +113,6 @@ public class ContextMenuTree {
});
contextMenu.add(openReportTemplate);
// contextMenu.add(new SeparatorMenuItem());
//Open Report Template
@ -138,19 +124,11 @@ public class ContextMenuTree {
openReport.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) {
// FileModel selected =
// treePanel.getSelectionModel().getSelectedItem();
FileModel selected = listSelectedItems.get(0);
// if(selected!=null)
// eventBus.fireEvent(new ImagePreviewEvent(selected,
// ce.getClientX(), ce.getClientY()));
if (selected != null){
eventBus.fireEvent(new OpenReportsEvent(selected));
}
//clearListSelectedItems();
}
});
@ -169,19 +147,13 @@ public class ContextMenuTree {
insertFolder.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) {
// final FileModel sourceFileModel = treePanel.getSelectionModel().getSelectedItem();
final FileModel sourceFileModel = listSelectedItems.get(0);
if (sourceFileModel != null) {
// final FolderModel parentFileModel = (FolderModel) treePanel.getStore().getParent(sourceFileModel); // TODO parent of item
eventBus.fireEvent(new AddFolderEvent(sourceFileModel, sourceFileModel.getParentFileModel()));
}
//clearListSelectedItems();
}
});
@ -205,7 +177,6 @@ public class ContextMenuTree {
});
contextMenu.add(createShareFolder);
// contextMenu.add(new SeparatorMenuItem());
//Add Url
@ -216,8 +187,7 @@ public class ContextMenuTree {
addUrl.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) {
// FileModel selected = treePanel.getSelectionModel().getSelectedItem();
FileModel selected = listSelectedItems.get(0);
FileModel parent = getDirectoryOrParent(selected);
@ -226,7 +196,6 @@ public class ContextMenuTree {
eventBus.fireEvent(new CreateUrlEvent(null, parent));
}
//clearListSelectedItems();
}
});
@ -240,13 +209,11 @@ public class ContextMenuTree {
copy.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) {
// List<FileModel> selected = treePanel.getSelectionModel().getSelectedItems();
for (FileModel target : listSelectedItems) {
if(target.getIdentifier()!=null){
CopyAndPaste.copy(target.getIdentifier());
}
}
//clearListSelectedItems();
}
});
@ -260,30 +227,18 @@ public class ContextMenuTree {
paste.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) {
// List<FileModel> selected = treePanel.getSelectionModel().getSelectedItems();
for (FileModel target : listSelectedItems) {
FileModel parentTarget = getDirectoryOrParent(target);
if(parentTarget!=null){
// FileModel source = treePanel.getStore().findModel(ConstantsExplorer.IDENTIFIER, CopyAndPaste.getCopiedfileModelId());
//// FileModel parentSource = source.getParentFileModel();
// if(parentSource.getIdentifier() != parentTarget.getIdentifier()){
eventBus.fireEvent(new PasteItemEvent(CopyAndPaste.getCopiedfileModelId(), parentTarget.getIdentifier()));
CopyAndPaste.setCopiedfileModelId(null);
// }
// else
// new MessageBoxAlert("Error", "desti", null);
eventBus.fireEvent(new PasteItemEvent(CopyAndPaste.getCopiedfileModelId(), parentTarget.getIdentifier()));
CopyAndPaste.setCopiedfileModelId(null);
}
}
//clearListSelectedItems();
}
});
@ -295,15 +250,13 @@ public class ContextMenuTree {
share.setIcon(Resources.getIconShareFolder());
share.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) {
// List<FileModel> selected = treePanel.getSelectionModel().getSelectedItems();
public void componentSelected(MenuEvent ce) {
for (FileModel target : listSelectedItems) {
if(target.getIdentifier()!=null){
eventBus.fireEvent(new CreateSharedFolderEvent(target, target.getParentFileModel(),false));
}
}
//clearListSelectedItems();
}
});
@ -317,14 +270,12 @@ public class ContextMenuTree {
unShare.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) {
// List<FileModel> selected = treePanel.getSelectionModel().getSelectedItems();
for (FileModel target : listSelectedItems) {
if(target.getIdentifier()!=null){
eventBus.fireEvent( new UnShareFolderEvent(target));
}
}
//clearListSelectedItems();
}
});
@ -339,15 +290,12 @@ public class ContextMenuTree {
rename.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) {
// List<FileModel> selected = treePanel.getSelectionModel().getSelectedItems();
for (FileModel target : listSelectedItems) {
if(target.getIdentifier()!=null){
eventBus.fireEvent(new RenameItemEvent(target));
// //clearListSelectedItems();
}
}
//clearListSelectedItems();
}
});
@ -361,13 +309,11 @@ public class ContextMenuTree {
remove.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) {
// List<FileModel> selected = treePanel.getSelectionModel().getSelectedItems();
for (FileModel sel : listSelectedItems) {
eventBus.fireEvent(new DeleteItemEvent(sel));
}
//clearListSelectedItems();
}
});
@ -383,7 +329,6 @@ public class ContextMenuTree {
show.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) {
// List<FileModel> selected = treePanel.getSelectionModel().getSelectedItems();
for (final FileModel sel : listSelectedItems) {
eventBus.fireEvent(new FileDownloadEvent(sel.getIdentifier(), sel.getName(), DownloadType.SHOW));
@ -403,14 +348,11 @@ public class ContextMenuTree {
viewWebDav.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) {
// List<FileModel> selected = treePanel.getSelectionModel().getSelectedItems();
for (final FileModel sel : listSelectedItems)
eventBus.fireEvent(new WebDavUrlEvent(sel.getIdentifier()));
//clearListSelectedItems();
}
});
@ -426,15 +368,10 @@ public class ContextMenuTree {
sendTo.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) {
// List<FileModel> selected = treePanel.getSelectionModel().getSelectedItems();
if(listSelectedItems!=null && listSelectedItems.size()>0)
eventBus.fireEvent(new SendMessageEvent(listSelectedItems));
//clearListSelectedItems();
}
});
@ -450,23 +387,14 @@ public class ContextMenuTree {
upload.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) {
// List<FileModel> selected = treePanel.getSelectionModel().getSelectedItems();
for (final FileModel sel : listSelectedItems) {
FileModel parent = getDirectoryOrParent(sel);
// if(sel.isDirectory())
// parent = sel;
// else
// parent = sel.getParentFileModel();
eventBus.fireEvent(new FileUploadEvent(parent, UploadType.FILE));
}
//clearListSelectedItems();
}
});
@ -481,24 +409,14 @@ public class ContextMenuTree {
uploadArchive.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) {
// List<FileModel> selected = treePanel.getSelectionModel().getSelectedItems();
for (FileModel sel : listSelectedItems) {
FileModel parent = getDirectoryOrParent(sel);
// if(sel.isDirectory())
// parent = sel;
// else
// parent = sel.getParentFileModel();
eventBus.fireEvent(new FileUploadEvent(parent, UploadType.ARCHIVE));
}
//clearListSelectedItems();
}
});
@ -512,26 +430,10 @@ public class ContextMenuTree {
downloadArchive.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) {
// List<FileModel> selected = treePanel.getSelectionModel().getSelectedItems();
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));
}
//clearListSelectedItems();
}
});
@ -546,14 +448,10 @@ public class ContextMenuTree {
refreshItem.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) {
// List<FileModel> selected = treePanel.getSelectionModel().getSelectedItems();
for (FileModel sel : listSelectedItems) {
eventBus.fireEvent(new RefreshFolderEvent(sel));
}
//clearListSelectedItems();
}
});
@ -568,8 +466,6 @@ public class ContextMenuTree {
public void openContextMenuOnItem(FileModel targetFileModel, int posX, int posY) {
// this.contextMenuPosX = posX;
// this.contextMenuPosY = posY;
clearListSelectedItems();
listSelectedItems.add(0, targetFileModel);

@ -1229,6 +1229,13 @@ public class GWTWorkspaceBuilder {
return fileModel;
}
/**
*
* @param wsFolder
* @param parent
* @return
* @throws InternalErrorException
*/
public FolderModel buildGXTFolderModelItem(WorkspaceFolder wsFolder, FileModel parent) throws InternalErrorException {
return new FolderModel(wsFolder.getId(),wsFolder.getName(), parent, true, wsFolder.isShared());
@ -1431,11 +1438,11 @@ public class GWTWorkspaceBuilder {
}
//THIS IS A TEST
listContactsModel.add(new InfoContactModel("1", "Federico.Test", "Federico de Faveri"));
listContactsModel.add(new InfoContactModel("2", "Antonio.Test", "Antonio Gioia"));
listContactsModel.add(new InfoContactModel("3", "Fabio.Test", "Fabio Sinibaldi"));
listContactsModel.add(new InfoContactModel("4", Util.TEST_USER, Util.TEST_USER));
listContactsModel.add(new InfoContactModel("5", "Massimiliano.Assante", "Massimiliano Assante"));
listContactsModel.add(new InfoContactModel("Federico.Test", "Federico.Test", "Federico de Faveri"));
listContactsModel.add(new InfoContactModel("Antonio.Test", "Antonio.Test", "Antonio Gioia"));
listContactsModel.add(new InfoContactModel("Fabio.Test", "Fabio.Test", "Fabio Sinibaldi"));
listContactsModel.add(new InfoContactModel(Util.TEST_USER, Util.TEST_USER, Util.TEST_USER));
listContactsModel.add(new InfoContactModel("massimiliano.assante", "massimiliano.assante", "Massimiliano Assante"));
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.rpc.GWTWorkspaceService;
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.Util;
@ -55,8 +56,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
public static final String LAST_OPEN_FOLDER_ATTRIBUTE = "WORKSPACE.LAST_OPEN_FOLDER";
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()
{
return Util.getGWTWorkspaceBuilder(this.getThreadLocalRequest().getSession());
@ -66,6 +68,15 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
{
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
public FolderModel getRootForTree() throws Exception {
@ -638,7 +649,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
return builder.buildGWTWorkspaceImage(item, isInteralImage, fullDetails);
// workspaceLogger.trace(" children "+wsFolder.getChildren().size());
// return builder.buildGWTWorkspaceItemsForGrid(wsFolder.getChildren(), null);
} catch (Exception e) {
@ -710,11 +720,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
logger.info("create url in parent id: "+parentFileModel.getIdentifier());
//DEBUG
// workspaceLogger.trace("Name " + name);
// workspaceLogger.trace("description " + description);
// workspaceLogger.trace("url " + url);
// workspaceLogger.trace("parentFileModel " + parentFileModel.getIdentifier() + " " + parentFileModel.getName());
// workspaceLogger.trace("parentFileModel " + parentFileModel.getIdentifier() + " " + parentFileModel.getName());
// if(description == null)
// description = "";
@ -1313,6 +1323,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
}
boolean created = sharedFolder==null?false:true;
if(created){
NotificationsProducer np = getNotificationProducer();
np.notifyFolderSharing(listContacts, sharedFolder);
}
return created;
} catch (Exception e) {
@ -1344,9 +1361,10 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
return builder.buildGxtInfoContactFromPortalLogin(listUser);
}
else
workspaceLogger.trace("the item with id: "+folderSharedId+ "is not "+WorkspaceItemType.SHARED_FOLDER);
else{
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>();
} catch (Exception e) {
@ -1364,7 +1382,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
try {
Workspace workspace = getWorkspace();
WorkspaceItem wsItem = workspace.getItem(folderSharedId);
if(wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
@ -1374,15 +1391,72 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
WorkspaceFolder unSharedFolder = wsFolder.unShare();
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
workspaceLogger.trace("the item with id: "+folderSharedId+ "is not "+WorkspaceItemType.SHARED_FOLDER);
} catch (Exception e) {
workspaceLogger.error("Error in unSharedFolderByFolderSharedId ", e);
e.printStackTrace();
throw new Exception(e.getMessage());
}
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.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.GCUBELog;
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.exceptions.WorkspaceFolderNotFoundException;
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 WORKSPACE_EVENT_COLLECTOR_ATTRIBUTE = "EVENT_COLLECTOR";
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_USER = "pasquale.pagano";
@ -35,9 +42,9 @@ public class Util {
public static final String TEST_SCOPE = "/gcube/devsec/devVRE";
// public static final String TEST_USER = "federico.defaveri";
// 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 = "francesco.mangiacrapa";
public static final String TEST_USER_FULL_NAME = "Francesco Mangiacrapa";
public static GCUBEClientLog defaultLogger = new GCUBEClientLog("WorkspacePortlet");
@ -54,7 +61,8 @@ public class Util {
httpSession.setAttribute(USERNAME_ATTRIBUTE, TEST_USER);
ASLSession session = SessionManager.getInstance().getASLSession(sessionID, TEST_USER);
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;
}
@ -156,5 +164,40 @@ public class Util {
ASLSession session = getAslSession(httpSession);
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…
Cancel
Save