git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@69632 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
5d6f91bbec
commit
0f1b52824c
|
@ -263,6 +263,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
|||
|
||||
//create a lowest object to send to server
|
||||
fileModel = new FileModel(fileModel.getIdentifier(), fileModel.getName(), fileModel.getParentFileModel(), fileModel.isDirectory(), fileModel.isShared());
|
||||
fileModel.setDescription(finalDialog.getDescription());
|
||||
}
|
||||
|
||||
//DEBUG
|
||||
|
|
|
@ -110,6 +110,7 @@ public class ConstantsExplorer {
|
|||
public static final String MARKASREAD = "MARKASREAD";
|
||||
public static final String ISROOT = "ISROOT";
|
||||
public static final String ISSHAREABLE = "ISSHAREABLE";
|
||||
public static final String DIRECTORYDESCRIPTION = "DIRECTORYDESCRIPTION";
|
||||
|
||||
|
||||
//GRID COLUMNS constants
|
||||
|
|
|
@ -26,22 +26,18 @@ public class FileDetailsModel extends FileGridModel {
|
|||
// this.setLastModified(lastModified);
|
||||
// }
|
||||
|
||||
public FileDetailsModel(String identifier, String name, String path, Date creationDate, FileModel parent, long size, boolean isDirectory, String description, Date lastModified, String owner, boolean isShared) {
|
||||
public FileDetailsModel(String identifier, String name, String path, Date creationDate, FileModel parent, long size, boolean isDirectory, String description, Date lastModified, InfoContactModel owner, boolean isShared) {
|
||||
super(identifier,name,path,creationDate,parent,size,isDirectory, isShared);
|
||||
|
||||
setLastModified(lastModified);
|
||||
setDescription(description);
|
||||
setDescription(owner);
|
||||
setOwner(owner);
|
||||
|
||||
}
|
||||
|
||||
public void setLastModified(Date lastModified) {
|
||||
set(ConstantsExplorer.LASTMODIFIED, lastModified);
|
||||
}
|
||||
|
||||
private void setDescription(String description){
|
||||
set(ConstantsExplorer.DESCRIPTION, description);
|
||||
}
|
||||
|
||||
private Date getLastModified() {
|
||||
return (Date) get(ConstantsExplorer.LASTMODIFIED);
|
||||
|
|
|
@ -69,6 +69,14 @@ public class FileModel extends BaseModelData implements Serializable {
|
|||
|
||||
}
|
||||
|
||||
public void setDescription(String description){
|
||||
set(ConstantsExplorer.DIRECTORYDESCRIPTION, description);
|
||||
}
|
||||
|
||||
public String getDescription(){
|
||||
return get(ConstantsExplorer.DIRECTORYDESCRIPTION);
|
||||
}
|
||||
|
||||
public boolean isShareable() {
|
||||
return (Boolean) get(ConstantsExplorer.ISSHAREABLE);
|
||||
|
||||
|
|
|
@ -113,6 +113,8 @@ public interface GWTWorkspaceService extends RemoteService{
|
|||
public List<FileModel> getListParentsByItemIdentifier(String itemIdentifier) throws Exception;
|
||||
|
||||
public String getURLFromApplicationProfile(String oid) throws Exception;
|
||||
|
||||
public InfoContactModel getOwnerByItemId(String itemId) throws Exception;
|
||||
|
||||
// public ArrayList<List<FileModel>> getChildrenListsByParentsIdentifier(String itemIdentifier) throws Exception;
|
||||
|
||||
|
|
|
@ -119,6 +119,9 @@ public interface GWTWorkspaceServiceAsync {
|
|||
|
||||
void getURLFromApplicationProfile(String oid, AsyncCallback<String> callback);
|
||||
|
||||
void getOwnerByItemId(String itemId,
|
||||
AsyncCallback<InfoContactModel> callback);
|
||||
|
||||
// void getListParentsByItemIdentifier(String itemIdentifier,AsyncCallback<ArrayList<String>> callback);
|
||||
|
||||
// void getChildrenListsByParentsIdentifier(String itemIdentifier,AsyncCallback<ArrayList<List<FileModel>>> callback);
|
||||
|
|
|
@ -11,5 +11,6 @@ public interface ContactFetcher {
|
|||
public void getListContact(AsyncCallback<List<InfoContactModel>> callback, boolean reloadList);
|
||||
public void getListSharedUserByFolderId(String sharedFolderId, AsyncCallback<List<InfoContactModel>> callback);
|
||||
public List<InfoContactModel> getExclusiveContactsFromAllContact(List<InfoContactModel> listSharedUser);
|
||||
public void getOwner(String sharedFolderId, AsyncCallback<InfoContactModel> callback);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.gcube.portlets.user.workspace.client.view.sharing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
||||
|
@ -41,6 +42,37 @@ public class DialogShareFolder extends Dialog {
|
|||
private UserStore userStore = new UserStore();
|
||||
private MultiValuePanel suggestPanel = new MultiValuePanel(userStore);
|
||||
private Button buttonMultiDrag = new Button("Choose Contacts");
|
||||
private TextField<String> txtOwner;
|
||||
|
||||
private List<InfoContactModel> listAlreadyShared = new ArrayList<InfoContactModel>(){
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Compare Login
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
|
||||
if(o==null)
|
||||
return false;
|
||||
|
||||
InfoContactModel contact = (InfoContactModel) o;
|
||||
|
||||
for (int i = 0; i < listAlreadyShared.size(); i++){
|
||||
if (contact.getLogin().compareTo(listAlreadyShared.get(i).getLogin())==0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Use to modify a shared folder or share an existing folder
|
||||
|
@ -63,10 +95,19 @@ public class DialogShareFolder extends Dialog {
|
|||
txtName.setReadOnly(true);
|
||||
txtName.setAutoValidate(true);
|
||||
txtName.setFieldLabel("Folder Name");
|
||||
|
||||
txtOwner = new TextField<String>();
|
||||
txtOwner.setAllowBlank(true);
|
||||
txtOwner.setValue("");
|
||||
txtOwner.setReadOnly(true);
|
||||
txtOwner.setAutoValidate(false);
|
||||
txtOwner.setFieldLabel("Owner");
|
||||
|
||||
textAreaDescription.setFieldLabel(ConstantsExplorer.DIALOG_DESCRIPTION);
|
||||
textAreaDescription.setHeight(heightTextArea);
|
||||
textAreaDescription.setWidth(380);
|
||||
textAreaDescription.setValue(folder.getDescription());
|
||||
textAreaDescription.setReadOnly(true);
|
||||
|
||||
final LayoutContainer lc = new LayoutContainer();
|
||||
lc.setStyleAttribute("margin-top", "10px");
|
||||
|
@ -89,6 +130,7 @@ public class DialogShareFolder extends Dialog {
|
|||
flexTable.setWidget(2, 0, labelDescription);
|
||||
flexTable.setWidget(2, 1, textAreaDescription);
|
||||
|
||||
|
||||
lc.add(flexTable);
|
||||
|
||||
lc.mask();
|
||||
|
@ -98,6 +140,7 @@ public class DialogShareFolder extends Dialog {
|
|||
public void onSuccess(List<InfoContactModel> result) {
|
||||
|
||||
for (InfoContactModel infoContactModel : result) {
|
||||
listAlreadyShared.add(infoContactModel);
|
||||
suggestPanel.addRecipient(infoContactModel.getLogin(),false);
|
||||
}
|
||||
|
||||
|
@ -110,9 +153,25 @@ public class DialogShareFolder extends Dialog {
|
|||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
userStore.getOwner(folder.getIdentifier(), new AsyncCallback<InfoContactModel>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(InfoContactModel result) {
|
||||
txtOwner.setValue(result.getLogin());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
setFocusWidget(suggestPanel.getBox());
|
||||
add(txtName);
|
||||
add(txtOwner);
|
||||
add(lc);
|
||||
addListners();
|
||||
|
||||
|
@ -224,7 +283,14 @@ public class DialogShareFolder extends Dialog {
|
|||
final MultiDragContact multiDrag = new MultiDragContact();
|
||||
List<InfoContactModel> exclusiveContacts = userStore.getExclusiveContactsFromAllContact(suggestPanel.getSelectedUser());
|
||||
multiDrag.addSourceContacts(exclusiveContacts);
|
||||
multiDrag.addTargetContacts(suggestPanel.getSelectedUser());
|
||||
|
||||
|
||||
for (InfoContactModel infoContactModel : suggestPanel.getSelectedUser()) {
|
||||
if(!listAlreadyShared.contains(infoContactModel))
|
||||
multiDrag.addTargetContact(infoContactModel);
|
||||
}
|
||||
|
||||
// multiDrag.addTargetContacts(suggestPanel.getSelectedUser());
|
||||
multiDrag.show();
|
||||
|
||||
multiDrag.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
@ -232,7 +298,7 @@ public class DialogShareFolder extends Dialog {
|
|||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
|
||||
suggestPanel.resetItemSelected();
|
||||
initSuggestContacts();
|
||||
|
||||
for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
|
||||
suggestPanel.addRecipient(infoContactModel.getLogin(),true);
|
||||
|
@ -244,6 +310,17 @@ public class DialogShareFolder extends Dialog {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initSuggestContacts(){
|
||||
|
||||
suggestPanel.resetItemSelected();
|
||||
|
||||
for (InfoContactModel contact : listAlreadyShared) {
|
||||
suggestPanel.addRecipient(contact.getLogin(), false);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return txtName.getValue();
|
||||
|
|
|
@ -91,4 +91,23 @@ public class UserStore implements ContactFetcher{
|
|||
|
||||
return listExclusiveContact;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getOwner(final String sharedFolderId,final AsyncCallback<InfoContactModel> callback) {
|
||||
|
||||
AppControllerExplorer.rpcWorkspaceService.getOwnerByItemId(sharedFolderId, new AsyncCallback<InfoContactModel>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
GWT.log("an error occured in get Owner by Id "+sharedFolderId + " "+caught.getMessage());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(InfoContactModel result) {
|
||||
callback.onSuccess(result);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -155,6 +155,11 @@ public class MultiDragContact extends Dialog {
|
|||
storeTarget.add(listContact);
|
||||
}
|
||||
|
||||
public void addTargetContact(InfoContactModel contact){
|
||||
if(contact!=null)
|
||||
storeTarget.add(contact);
|
||||
}
|
||||
|
||||
public List<InfoContactModel> getTargetListContact(){
|
||||
return storeTarget.getModels();
|
||||
}
|
||||
|
|
|
@ -220,14 +220,16 @@ public class MultiValuePanel extends Composite {
|
|||
listBullet.add(item);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* insert the attachment item view in the flow panel
|
||||
* @param fullName
|
||||
*
|
||||
* @param contact
|
||||
* @param displayRemoveItem
|
||||
*/
|
||||
public void addRecipient(String fullName, boolean displayRemoveItem) {
|
||||
|
||||
if (fullName != null) {
|
||||
|
||||
TextBox itemBox = new TextBox();
|
||||
itemBox.setText(fullName);
|
||||
itemBox.setValue(fullName);
|
||||
|
|
|
@ -860,6 +860,7 @@ public class GWTWorkspaceBuilder {
|
|||
fileModel = new FolderModel(item.getId(), item.getName(), (FolderModel) parentFolderModel, true, false);
|
||||
fileModel.setType(GXTFolderItemTypeEnum.FOLDER.toString());
|
||||
fileModel.setShareable(true);
|
||||
fileModel.setDescription(item.getDescription());
|
||||
break;
|
||||
|
||||
case FOLDER_ITEM:
|
||||
|
@ -875,6 +876,7 @@ public class GWTWorkspaceBuilder {
|
|||
fileModel = new FolderModel(item.getId(), item.getName(), (FolderModel) parentFolderModel, true, true);
|
||||
fileModel.setType(GXTFolderItemTypeEnum.SHARED_FOLDER.toString());
|
||||
fileModel.setShareable(true);
|
||||
fileModel.setDescription(item.getDescription());
|
||||
|
||||
// WorkspaceSharedFolder sharedFolder = (WorkspaceSharedFolder) item;
|
||||
// fileModel.setListShareUser(buildGxtInfoContactFromPortalLogin(sharedFolder.getUsers()));
|
||||
|
@ -939,6 +941,7 @@ public class GWTWorkspaceBuilder {
|
|||
fileGridModel.setType(GXTFolderItemTypeEnum.SHARED_FOLDER.toString());
|
||||
fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||||
fileGridModel.setShareable(true);
|
||||
// fileGridModel.setDescription(item.getDescription()); // GET DESCRIPTION IN SEARCH //TODO
|
||||
// WorkspaceSharedFolder sharedFolder = (WorkspaceSharedFolder) item;
|
||||
// fileGridModel.setListShareUser(buildGxtInfoContactFromPortalLogin(sharedFolder.getUsers()));
|
||||
|
||||
|
@ -996,6 +999,7 @@ public class GWTWorkspaceBuilder {
|
|||
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER.toString());
|
||||
fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||||
fileGridModel.setShareable(true);
|
||||
fileGridModel.setDescription(item.getDescription());
|
||||
break;
|
||||
|
||||
case FOLDER_ITEM:
|
||||
|
@ -1011,6 +1015,7 @@ public class GWTWorkspaceBuilder {
|
|||
fileGridModel.setType(GXTFolderItemTypeEnum.SHARED_FOLDER.toString());
|
||||
fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||||
fileGridModel.setShareable(true);
|
||||
fileGridModel.setDescription(item.getDescription());
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -1252,7 +1257,8 @@ public class GWTWorkspaceBuilder {
|
|||
item.isDirectory(),
|
||||
wsItem.getDescription(),
|
||||
toDate(wsItem.getLastModificationTime()),
|
||||
""+wsItem.getOwner(),wsItem.isShared());
|
||||
buildGXTInfoContactModel(wsItem.getOwner()),
|
||||
wsItem.isShared());
|
||||
|
||||
return fileDetailsModel;
|
||||
}
|
||||
|
@ -1364,28 +1370,6 @@ public class GWTWorkspaceBuilder {
|
|||
return filteredList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// public SmartFolderModel buildGXTSmartFolderModel(WorkspaceFolder wsFolder, String query) throws InternalErrorException {
|
||||
//
|
||||
// SmartFolderModel smartFolderModel = new SmartFolderModel(
|
||||
// wsFolder.getId(),
|
||||
// wsFolder.getName(),
|
||||
// query);
|
||||
//
|
||||
// logger.trace("in return SmartFolder: " + smartFolderModel.getIdentifier() + " " + smartFolderModel.getName() + " " + smartFolderModel.getQuery());
|
||||
// return smartFolderModel;
|
||||
// }
|
||||
|
||||
// public List<SmartFolderModel> buildGXTListSmartFolderModel(List<WorkspaceFolder> listWorkspaceFolder) throws InternalErrorException {
|
||||
//
|
||||
// List<SmartFolderModel> listSmartFolder = new ArrayList<SmartFolderModel>();
|
||||
//
|
||||
// for(WorkspaceFolder workspaceFolder : listWorkspaceFolder)
|
||||
// listSmartFolder.add(buildGXTSmartFolderModel(workspaceFolder, ""));
|
||||
//
|
||||
// return listSmartFolder;
|
||||
// }
|
||||
|
||||
public List<SmartFolderModel> buildGXTListSmartFolderModel(List<WorkspaceSmartFolder> listWorkspaceSmartFolder) throws InternalErrorException {
|
||||
List<SmartFolderModel> listSmartFolder = new ArrayList<SmartFolderModel>();
|
||||
|
@ -1500,9 +1484,18 @@ public class GWTWorkspaceBuilder {
|
|||
}
|
||||
|
||||
|
||||
private InfoContactModel buildGXTInfoContactModel(User user) throws InternalErrorException{
|
||||
/**
|
||||
*
|
||||
* @param user
|
||||
* @return InfoContactModel
|
||||
* @throws InternalErrorException
|
||||
*/
|
||||
public InfoContactModel buildGXTInfoContactModel(User user) throws InternalErrorException{
|
||||
|
||||
return new InfoContactModel(user.getId(), user.getPortalLogin(), "name");
|
||||
if(user!=null)
|
||||
return new InfoContactModel(user.getId(), user.getPortalLogin(), "name");
|
||||
|
||||
return new InfoContactModel();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -849,7 +849,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
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"));
|
||||
listContactsModel.add(new InfoContactModel("francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa"));
|
||||
return listContactsModel;
|
||||
|
||||
}
|
||||
|
@ -1361,7 +1360,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
if(!isNewFolder)
|
||||
sharedFolder = workspace.shareFolder(listLogin, folder.getIdentifier());
|
||||
else
|
||||
sharedFolder = workspace.createSharedFolder(folder.getName(), "description", listLogin, folder.getParentFileModel().getIdentifier());
|
||||
sharedFolder = workspace.createSharedFolder(folder.getName(), folder.getDescription(), listLogin, folder.getParentFileModel().getIdentifier());
|
||||
}
|
||||
|
||||
boolean created = sharedFolder==null?false:true;
|
||||
|
@ -1524,4 +1523,24 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
|
||||
return listParents;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InfoContactModel getOwnerByItemId(String itemId) throws Exception {
|
||||
|
||||
workspaceLogger.trace("get Owner By ItemId "+ itemId);
|
||||
try {
|
||||
|
||||
Workspace workspace = getWorkspace();
|
||||
|
||||
WorkspaceItem wsItem = workspace.getItem(itemId);
|
||||
|
||||
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
||||
|
||||
return builder.buildGXTInfoContactModel(wsItem.getOwner());
|
||||
|
||||
} catch (Exception e) {
|
||||
workspaceLogger.error("Error in getOwnerByItemId ", e);
|
||||
throw new Exception(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,13 +66,20 @@ public class NotificationsProducer {
|
|||
for (InfoContactModel infoContactModel : listContacts) {
|
||||
try{
|
||||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
||||
if(infoContactModel.getId().compareTo(userId)!=0){
|
||||
// if(infoContactModel.getId().compareTo(userId)!=0){ //TODO remove this comment
|
||||
|
||||
gcubeLogger.trace("Send notify folder sharing for user "+infoContactModel.getId());
|
||||
|
||||
|
||||
//DEBUG
|
||||
System.out.println("Send notify folder sharing for user "+infoContactModel.getId());
|
||||
|
||||
|
||||
boolean notify = notificationsMng.notifyFolderSharing(infoContactModel.getId(), sharedFolder);
|
||||
|
||||
if(!notify)
|
||||
gcubeLogger.error("An error occured when notify user: "+infoContactModel.getId());
|
||||
}
|
||||
// }
|
||||
}catch (Exception e) {
|
||||
gcubeLogger.error("An error occured in notifyFolderSharing ", e);
|
||||
e.printStackTrace();
|
||||
|
@ -104,16 +111,18 @@ public class NotificationsProducer {
|
|||
try{
|
||||
|
||||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
||||
if(infoContactModel.getId().compareTo(userId)!=0){
|
||||
// if(infoContactModel.getId().compareTo(userId)!=0){ //TODO remove this comment
|
||||
|
||||
gcubeLogger.trace("Send notify folder un share user "+infoContactModel.getId());
|
||||
// System.out.println("Send notify folder un share user "+infoContactModel.getId());
|
||||
|
||||
//DEBUG
|
||||
System.out.println("Send notify folder un share user "+infoContactModel.getId());
|
||||
|
||||
boolean notify = notificationsMng.notifyFolderRemovedUser(infoContactModel.getId(), sharedFolder, userId);
|
||||
|
||||
if(!notify)
|
||||
gcubeLogger.error("An error occured when notify user: "+infoContactModel.getId());
|
||||
}
|
||||
// }
|
||||
}catch (Exception e) {
|
||||
gcubeLogger.error("An error occured in notifyFolderSharing ", e);
|
||||
e.printStackTrace();
|
||||
|
|
Loading…
Reference in New Issue