This commit is contained in:
Francesco Mangiacrapa 2013-02-25 18:03:53 +00:00
parent 5d6f91bbec
commit 0f1b52824c
14 changed files with 178 additions and 42 deletions

View File

@ -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

View File

@ -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

View File

@ -26,12 +26,12 @@ 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);
}
@ -39,10 +39,6 @@ public class FileDetailsModel extends FileGridModel {
set(ConstantsExplorer.LASTMODIFIED, lastModified);
}
private void setDescription(String description){
set(ConstantsExplorer.DESCRIPTION, description);
}
private Date getLastModified() {
return (Date) get(ConstantsExplorer.LASTMODIFIED);
}

View File

@ -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);

View File

@ -114,6 +114,8 @@ public interface GWTWorkspaceService extends RemoteService{
public String getURLFromApplicationProfile(String oid) throws Exception;
public InfoContactModel getOwnerByItemId(String itemId) throws Exception;
// public ArrayList<List<FileModel>> getChildrenListsByParentsIdentifier(String itemIdentifier) throws Exception;
// public List<GWTUser> getUsers() throws Exception;

View File

@ -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);

View File

@ -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);
}

View File

@ -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
@ -64,9 +96,18 @@ public class DialogShareFolder extends Dialog {
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);
}
@ -111,8 +154,24 @@ 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);
@ -245,6 +311,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();
}

View File

@ -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);
}
});
}
}

View File

@ -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();
}

View File

@ -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);

View File

@ -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;
}
@ -1365,28 +1371,6 @@ public class GWTWorkspaceBuilder {
}
// 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{
if(user!=null)
return new InfoContactModel(user.getId(), user.getPortalLogin(), "name");
return new InfoContactModel();
}

View File

@ -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());
}
}
}

View File

@ -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();