ref 17169: Selection of users in the Sharing panel
https://support.d4science.org/issues/17169 Added users discovery by keyword search git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-sharing-widget@181296 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
9a41022e2c
commit
600dddc376
|
@ -8,17 +8,18 @@ import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
|
||||||
public interface ContactFetcher {
|
public interface ContactFetcher {
|
||||||
|
|
||||||
public void getListContact(AsyncCallback<List<InfoContactModel>> callback, boolean reloadList);
|
public void getListContact(AsyncCallback<List<InfoContactModel>> callback, boolean reloadList);
|
||||||
|
|
||||||
public void getListSharedUserByFolderId(String sharedFolderId, AsyncCallback<List<InfoContactModel>> callback);
|
public void getListSharedUserByFolderId(String sharedFolderId, AsyncCallback<List<InfoContactModel>> callback);
|
||||||
|
|
||||||
public List<InfoContactModel> getExclusiveContactsFromAllContact(List<InfoContactModel> listSharedUser);
|
public List<InfoContactModel> getExclusiveContactsFromAllContact(List<InfoContactModel> listSharedUser);
|
||||||
|
|
||||||
public void getOwner(String sharedFolderId, AsyncCallback<InfoContactModel> callback);
|
public void getOwner(String sharedFolderId, AsyncCallback<InfoContactModel> callback);
|
||||||
|
|
||||||
|
public void getInfoContactModelsFromCredential(List<CredentialModel> listAlreadySharedContact,
|
||||||
public void getInfoContactModelsFromCredential(
|
|
||||||
List<CredentialModel> listAlreadySharedContact,
|
|
||||||
AsyncCallback<List<InfoContactModel>> callback);
|
AsyncCallback<List<InfoContactModel>> callback);
|
||||||
|
|
||||||
public void getAdministratorsByFolderId(String sharedFolderId, AsyncCallback<List<InfoContactModel>> callback);
|
public void getAdministratorsByFolderId(String sharedFolderId, AsyncCallback<List<InfoContactModel>> callback);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,7 +190,7 @@ public class DialogShareWItem extends Dialog {
|
||||||
for (InfoContactModel infoContactModel : result) {
|
for (InfoContactModel infoContactModel : result) {
|
||||||
if (infoContactModel.getName() != null) {
|
if (infoContactModel.getName() != null) {
|
||||||
listAlreadyShared.add(infoContactModel);
|
listAlreadyShared.add(infoContactModel);
|
||||||
suggestPanel.addRecipient(infoContactModel.getName(), false);
|
suggestPanel.addRecipient(infoContactModel, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,7 +348,7 @@ public class DialogShareWItem extends Dialog {
|
||||||
initSuggestContacts();
|
initSuggestContacts();
|
||||||
|
|
||||||
for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
|
for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
|
||||||
suggestPanel.addRecipient(infoContactModel.getName(), true);
|
suggestPanel.addRecipient(infoContactModel, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// for (InfoContactModel infoContactModel :
|
// for (InfoContactModel infoContactModel :
|
||||||
|
@ -398,7 +398,7 @@ public class DialogShareWItem extends Dialog {
|
||||||
suggestPanel.resetItemSelected();
|
suggestPanel.resetItemSelected();
|
||||||
|
|
||||||
for (InfoContactModel contact : listAlreadyShared) {
|
for (InfoContactModel contact : listAlreadyShared) {
|
||||||
suggestPanel.addRecipient(contact.getName(), false);
|
suggestPanel.addRecipient(contact, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,9 +155,9 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<InfoContactModel> result) {
|
public void onSuccess(List<InfoContactModel> result) {
|
||||||
for (InfoContactModel infoContactModel : result) {
|
for (InfoContactModel infoContactModel : result) {
|
||||||
String name = infoContactModel.getName()!=null && !infoContactModel.getName().isEmpty()?infoContactModel.getName():infoContactModel.getLogin();
|
//String name = infoContactModel.getName()!=null && !infoContactModel.getName().isEmpty()?infoContactModel.getName():infoContactModel.getLogin();
|
||||||
listAlreadyShared.add(infoContactModel);
|
listAlreadyShared.add(infoContactModel);
|
||||||
suggestPanel.addRecipient(name,false);
|
suggestPanel.addRecipient(infoContactModel,false);
|
||||||
layout();
|
layout();
|
||||||
}
|
}
|
||||||
lc.unmask();
|
lc.unmask();
|
||||||
|
@ -317,7 +317,7 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
|
||||||
initSuggestContacts();
|
initSuggestContacts();
|
||||||
|
|
||||||
for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
|
for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
|
||||||
suggestPanel.addRecipient(infoContactModel.getName(),true);
|
suggestPanel.addRecipient(infoContactModel,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
|
// for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
|
||||||
|
@ -371,7 +371,7 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
|
||||||
suggestPanel.resetItemSelected();
|
suggestPanel.resetItemSelected();
|
||||||
|
|
||||||
for (InfoContactModel contact : listAlreadyShared) {
|
for (InfoContactModel contact : listAlreadyShared) {
|
||||||
suggestPanel.addRecipient(contact.getName(), false);
|
suggestPanel.addRecipient(contact, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@ public class UserStore implements ContactFetcher{
|
||||||
// public boolean syncronizeCleanSharedUser = false;
|
// public boolean syncronizeCleanSharedUser = false;
|
||||||
|
|
||||||
public UserStore() {
|
public UserStore() {
|
||||||
|
loadAllUsersFromServer();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,7 +32,7 @@ public class UserStore implements ContactFetcher{
|
||||||
loadSharedUserBySharedFolderId(sharedFolderId, callback);
|
loadSharedUserBySharedFolderId(sharedFolderId, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadAllUsersFromServer(final AsyncCallback<List<InfoContactModel>> callback){
|
private void loadAllUsersFromServer(){
|
||||||
|
|
||||||
listAllContact = new ArrayList<InfoContactModel>();
|
listAllContact = new ArrayList<InfoContactModel>();
|
||||||
|
|
||||||
|
@ -40,13 +42,11 @@ public class UserStore implements ContactFetcher{
|
||||||
public void onSuccess(List<InfoContactModel> result) {
|
public void onSuccess(List<InfoContactModel> result) {
|
||||||
GWT.log("Get all contacts loaded "+result.size() + " contacts from server");
|
GWT.log("Get all contacts loaded "+result.size() + " contacts from server");
|
||||||
listAllContact = result;
|
listAllContact = result;
|
||||||
callback.onSuccess(listAllContact);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
MessageBox.alert("Error", ConstantsSharing.SERVER_ERROR +" retrieving user " + ConstantsSharing.TRY_AGAIN, null);
|
MessageBox.alert("Error", ConstantsSharing.SERVER_ERROR +" retrieving user " + ConstantsSharing.TRY_AGAIN, null);
|
||||||
callback.onFailure(caught);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -128,10 +128,15 @@ public class UserStore implements ContactFetcher{
|
||||||
@Override
|
@Override
|
||||||
public void getListContact(AsyncCallback<List<InfoContactModel>> callback,boolean reloadList) {
|
public void getListContact(AsyncCallback<List<InfoContactModel>> callback,boolean reloadList) {
|
||||||
|
|
||||||
if(reloadList || listAllContact==null)
|
if(listAllContact==null||listAllContact.isEmpty()){
|
||||||
loadAllUsersFromServer(callback);
|
callback.onFailure(new Throwable("Error retrieving all users!"));
|
||||||
else
|
} else {
|
||||||
callback.onSuccess(listAllContact);
|
callback.onSuccess(listAllContact);
|
||||||
|
}
|
||||||
|
//if(reloadList || listAllContact==null)
|
||||||
|
// loadAllUsersFromServer(callback);
|
||||||
|
// else
|
||||||
|
// callback.onSuccess(listAllContact);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
package org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest;
|
||||||
|
|
||||||
|
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
||||||
|
|
||||||
|
import com.google.gwt.user.client.ui.SuggestOracle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Giancarlo Panichi
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class InfoContactModelSuggestion implements SuggestOracle.Suggestion {
|
||||||
|
|
||||||
|
private InfoContactModel infoContactModel;
|
||||||
|
|
||||||
|
public InfoContactModelSuggestion(InfoContactModel infoContactModel) {
|
||||||
|
this.infoContactModel = infoContactModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDisplayString() {
|
||||||
|
return getReplacementString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getReplacementString() {
|
||||||
|
if (infoContactModel != null && infoContactModel.getName() != null && !infoContactModel.getName().isEmpty()) {
|
||||||
|
if (infoContactModel.getEmailDomain() == null || infoContactModel.getEmailDomain().isEmpty()) {
|
||||||
|
return infoContactModel.getName();
|
||||||
|
} else {
|
||||||
|
return infoContactModel.getName() + " (" + infoContactModel.getEmailDomain() + ")";
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public InfoContactModel getInfoContactModel() {
|
||||||
|
return infoContactModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "InfoContactModelSuggestion [infoContactModel=" + infoContactModel + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -7,7 +7,6 @@ import java.util.List;
|
||||||
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.ContactFetcher;
|
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.ContactFetcher;
|
||||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
||||||
|
|
||||||
import com.extjs.gxt.ui.client.widget.MessageBox;
|
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
|
@ -16,7 +15,6 @@ import com.google.gwt.event.dom.client.KeyDownEvent;
|
||||||
import com.google.gwt.event.dom.client.KeyDownHandler;
|
import com.google.gwt.event.dom.client.KeyDownHandler;
|
||||||
import com.google.gwt.event.logical.shared.SelectionEvent;
|
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||||
import com.google.gwt.event.logical.shared.SelectionHandler;
|
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
import com.google.gwt.user.client.ui.FlowPanel;
|
import com.google.gwt.user.client.ui.FlowPanel;
|
||||||
import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
|
import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
|
||||||
|
@ -27,56 +25,66 @@ import com.google.gwt.user.client.ui.TextBox;
|
||||||
/**
|
/**
|
||||||
* The Class MultiValuePanel.
|
* The Class MultiValuePanel.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa
|
* @author Francesco Mangiacrapa Feb 25, 2014
|
||||||
* Feb 25, 2014
|
|
||||||
*/
|
*/
|
||||||
public class MultiValuePanel extends Composite {
|
public class MultiValuePanel extends Composite {
|
||||||
|
|
||||||
// private final WsMailServiceAsync mailingService = GWT.create(WsMailService.class);
|
// private final WsMailServiceAsync mailingService =
|
||||||
private List<String> itemsSelected = new ArrayList<String>();
|
// GWT.create(WsMailService.class);
|
||||||
|
// private List<String> itemsSelected = new ArrayList<>();
|
||||||
FlowPanel panel = new FlowPanel();
|
FlowPanel panel = new FlowPanel();
|
||||||
// private HandlerManager eventBus;
|
// private HandlerManager eventBus;
|
||||||
private HashMap<String, InfoContactModel> users = new HashMap<String, InfoContactModel>(); //AN HAST FULLNAME - INFOCONTACTMODEL
|
private HashMap<String, InfoContactModel> users = new HashMap<String, InfoContactModel>(); // AN
|
||||||
|
// HAST
|
||||||
|
// FULLNAME
|
||||||
|
// -
|
||||||
|
// INFOCONTACTMODEL
|
||||||
private BulletList listBullet = new BulletList();
|
private BulletList listBullet = new BulletList();
|
||||||
private SuggestBox box;
|
private SuggestBox box;
|
||||||
private ContactFetcher userFetch;
|
// private ContactFetcher userFetch;
|
||||||
private MultiWordSuggestOracle oracle = new MultiWordSuggestOracle(); //ORACLE OF FULL NAMES
|
private ServerMultiWordSuggestOracle oracle = new ServerMultiWordSuggestOracle(); // ORACLE
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new multi value panel.
|
* Instantiates a new multi value panel.
|
||||||
*
|
*
|
||||||
* @param userFetch the ContactFetcher
|
* @param userFetch
|
||||||
* @param readGroupsFromHL the read groups from hl
|
* the ContactFetcher
|
||||||
* @param readGroupsFromPortal the read groups from portal
|
* @param readGroupsFromHL
|
||||||
|
* the read groups from hl
|
||||||
|
* @param readGroupsFromPortal
|
||||||
|
* the read groups from portal
|
||||||
*/
|
*/
|
||||||
public MultiValuePanel(ContactFetcher userFetch) {
|
public MultiValuePanel(ContactFetcher userFetch) {
|
||||||
this.userFetch = userFetch;
|
// this.userFetch = userFetch;
|
||||||
initWidget(panel);
|
initWidget(panel);
|
||||||
panel.setWidth("100%");
|
panel.setWidth("100%");
|
||||||
listBullet.setStyleName("multivalue-panel-suggest");
|
listBullet.setStyleName("multivalue-panel-suggest");
|
||||||
final ListItem item = new ListItem();
|
final ListItem item = new ListItem();
|
||||||
final TextBox itemBox = new TextBox();
|
final TextBox itemBox = new TextBox();
|
||||||
itemBox.getElement().setAttribute("style", "outline-color: -moz-use-text-color; outline-style: none; outline-width: medium; border: none;");
|
itemBox.getElement().setAttribute("style",
|
||||||
box = new SuggestBox(getSuggestions(), itemBox);
|
"outline-color: -moz-use-text-color; outline-style: none; outline-width: medium; border: none;");
|
||||||
|
box = new SuggestBox(oracle, itemBox);
|
||||||
|
|
||||||
item.add(box);
|
item.add(box);
|
||||||
listBullet.add(item);
|
listBullet.add(item);
|
||||||
|
|
||||||
// needed to be set on the itemBox instead of the box, otherwise backspace gets executed twice
|
// needed to be set on the itemBox instead of the box, otherwise
|
||||||
|
// backspace gets executed twice
|
||||||
itemBox.addKeyDownHandler(new KeyDownHandler() {
|
itemBox.addKeyDownHandler(new KeyDownHandler() {
|
||||||
public void onKeyDown(KeyDownEvent event) {
|
public void onKeyDown(KeyDownEvent event) {
|
||||||
// handle backspace
|
// handle backspace
|
||||||
if (event.getNativeKeyCode() == KeyCodes.KEY_BACKSPACE) {
|
if (event.getNativeKeyCode() == KeyCodes.KEY_BACKSPACE) {
|
||||||
if ("".equals(itemBox.getValue().trim())) {
|
if ("".equals(itemBox.getValue().trim())) {
|
||||||
|
|
||||||
if(listBullet.getWidgetCount()>2){
|
if (listBullet.getWidgetCount() > 2) {
|
||||||
ListItem li = (ListItem) listBullet.getWidget(listBullet.getWidgetCount() - 2);
|
ListItem li = (ListItem) listBullet.getWidget(listBullet.getWidgetCount() - 2);
|
||||||
|
|
||||||
if(li.getWidget(0) instanceof Paragraph){
|
if (li.getWidget(0) instanceof Paragraph) {
|
||||||
Paragraph p = (Paragraph) li.getWidget(0);
|
Paragraph p = (Paragraph) li.getWidget(0);
|
||||||
GWT.log("p "+p.getText() +" is removable : " + p.isRemovable());
|
GWT.log("p " + p.getText() + " is removable : " + p.isRemovable());
|
||||||
if (itemsSelected.contains(p.getText()) && p.isRemovable()==true) {
|
if (users.containsKey(p.getText()) && p.isRemovable() == true) {
|
||||||
itemsSelected.remove(p.getText());
|
users.remove(p.getText());
|
||||||
GWT.log("Removing selected item: " + p.getText() + "'");
|
GWT.log("Removing selected item: " + p.getText() + "'");
|
||||||
listBullet.remove(li);
|
listBullet.remove(li);
|
||||||
}
|
}
|
||||||
|
@ -90,20 +98,23 @@ public class MultiValuePanel extends Composite {
|
||||||
});
|
});
|
||||||
|
|
||||||
box.addSelectionHandler(new SelectionHandler<SuggestOracle.Suggestion>() {
|
box.addSelectionHandler(new SelectionHandler<SuggestOracle.Suggestion>() {
|
||||||
|
|
||||||
public void onSelection(SelectionEvent<SuggestOracle.Suggestion> selectionEvent) {
|
public void onSelection(SelectionEvent<SuggestOracle.Suggestion> selectionEvent) {
|
||||||
chosenContactItem(itemBox, listBullet);
|
InfoContactModelSuggestion suggest = (InfoContactModelSuggestion) selectionEvent.getSelectedItem();
|
||||||
|
chosenContactItem(suggest, itemBox, listBullet);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
panel.add(listBullet);
|
panel.add(listBullet);
|
||||||
box.getElement().setId("suggestion_box"); //needed for the focus on click
|
box.getElement().setId("suggestion_box"); // needed for the focus on
|
||||||
|
// click
|
||||||
panel.getElement().setAttribute("onclick", "document.getElementById('suggestion_box').focus()");
|
panel.getElement().setAttribute("onclick", "document.getElementById('suggestion_box').focus()");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Box set focus.
|
* Box set focus.
|
||||||
*/
|
*/
|
||||||
public void boxSetFocus(){
|
public void boxSetFocus() {
|
||||||
box.getElement().focus();
|
box.getElement().focus();
|
||||||
box.setFocus(true);
|
box.setFocus(true);
|
||||||
}
|
}
|
||||||
|
@ -113,17 +124,19 @@ public class MultiValuePanel extends Composite {
|
||||||
*
|
*
|
||||||
* @return the flow panel
|
* @return the flow panel
|
||||||
*/
|
*/
|
||||||
public FlowPanel getFlowPanel(){
|
public FlowPanel getFlowPanel() {
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* actually insert the contact in the flow panel.
|
* actually insert the contact in the flow panel.
|
||||||
*
|
*
|
||||||
* @param itemBox the item box
|
* @param itemBox
|
||||||
* @param list the list
|
* the item box
|
||||||
|
* @param list
|
||||||
|
* the list
|
||||||
*/
|
*/
|
||||||
private void chosenContactItem(final TextBox itemBox, final BulletList list) {
|
private void chosenContactItem(InfoContactModelSuggestion suggest, final TextBox itemBox, final BulletList list) {
|
||||||
if (itemBox.getValue() != null && !itemBox.getValue().trim().isEmpty()) {
|
if (itemBox.getValue() != null && !itemBox.getValue().trim().isEmpty()) {
|
||||||
final ListItem displayItem = new ListItem();
|
final ListItem displayItem = new ListItem();
|
||||||
displayItem.setStyleName("multivalue-panel-token-ws");
|
displayItem.setStyleName("multivalue-panel-token-ws");
|
||||||
|
@ -139,10 +152,11 @@ public class MultiValuePanel extends Composite {
|
||||||
displayItem.add(p);
|
displayItem.add(p);
|
||||||
displayItem.add(span);
|
displayItem.add(span);
|
||||||
|
|
||||||
//original value of the item selected
|
// original value of the item selected
|
||||||
GWT.log("Adding selected item '" + itemBox.getValue());
|
GWT.log("Adding selected item '" + itemBox.getValue());
|
||||||
itemsSelected.add(itemBox.getValue());
|
// itemsSelected.add(itemBox.getValue());
|
||||||
GWT.log("Total: " + itemsSelected);
|
// GWT.log("Total: " + itemsSelected);
|
||||||
|
users.put(itemBox.getValue(), suggest.getInfoContactModel());
|
||||||
|
|
||||||
list.insert(displayItem, list.getWidgetCount() - 1);
|
list.insert(displayItem, list.getWidgetCount() - 1);
|
||||||
itemBox.setValue("");
|
itemBox.setValue("");
|
||||||
|
@ -160,11 +174,11 @@ public class MultiValuePanel extends Composite {
|
||||||
return new ArrayList<InfoContactModel>();
|
return new ArrayList<InfoContactModel>();
|
||||||
else {
|
else {
|
||||||
List<InfoContactModel> toReturn = new ArrayList<InfoContactModel>();
|
List<InfoContactModel> toReturn = new ArrayList<InfoContactModel>();
|
||||||
// GWT.log("Selected User: "+itemsSelected);
|
// GWT.log("Selected User: "+itemsSelected);
|
||||||
// GWT.log("users: "+users);
|
// GWT.log("users: "+users);
|
||||||
for (String fullName : itemsSelected) {
|
for (String fullName : users.keySet()) {
|
||||||
InfoContactModel wsuser = users.get(fullName);
|
InfoContactModel wsuser = users.get(fullName);
|
||||||
if(wsuser!= null && !toReturn.contains(wsuser))
|
if (wsuser != null && !toReturn.contains(wsuser))
|
||||||
toReturn.add(wsuser);
|
toReturn.add(wsuser);
|
||||||
}
|
}
|
||||||
return toReturn;
|
return toReturn;
|
||||||
|
@ -174,12 +188,15 @@ public class MultiValuePanel extends Composite {
|
||||||
/**
|
/**
|
||||||
* Removes the list item.
|
* Removes the list item.
|
||||||
*
|
*
|
||||||
* @param displayItem the display item
|
* @param displayItem
|
||||||
* @param list the list
|
* the display item
|
||||||
|
* @param list
|
||||||
|
* the list
|
||||||
*/
|
*/
|
||||||
private void removeListItem(ListItem displayItem, BulletList list) {
|
private void removeListItem(ListItem displayItem, BulletList list) {
|
||||||
GWT.log("Removing: " + displayItem.getWidget(0).getElement().getInnerHTML(), null);
|
GWT.log("Removing: " + displayItem.getWidget(0).getElement().getInnerHTML(), null);
|
||||||
itemsSelected.remove(displayItem.getWidget(0).getElement().getInnerHTML());
|
// itemsSelected.remove(displayItem.getWidget(0).getElement().getInnerHTML());
|
||||||
|
users.remove(displayItem.getWidget(0).getElement().getInnerHTML());
|
||||||
list.remove(displayItem);
|
list.remove(displayItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,83 +206,74 @@ public class MultiValuePanel extends Composite {
|
||||||
* @return names of possible contacts
|
* @return names of possible contacts
|
||||||
*/
|
*/
|
||||||
private MultiWordSuggestOracle getSuggestions() {
|
private MultiWordSuggestOracle getSuggestions() {
|
||||||
userFetch.getListContact(contacts, false);
|
// userFetch.getListContact(contacts, false);
|
||||||
return oracle;
|
return oracle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
/**
|
* /** Update suggestions.
|
||||||
* Update suggestions.
|
|
||||||
*
|
*
|
||||||
* @param result the result
|
* @param result the result
|
||||||
|
*
|
||||||
|
* public void updateSuggestions(List<InfoContactModel> result) {
|
||||||
|
*
|
||||||
|
* oracle.clear();
|
||||||
|
*
|
||||||
|
* for (InfoContactModel wsUser : result) { oracle.add(wsUser.getName());
|
||||||
|
*
|
||||||
|
* } }
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* private AsyncCallback<List<InfoContactModel>> contacts = new
|
||||||
|
* AsyncCallback<List<InfoContactModel>>() {
|
||||||
|
*
|
||||||
|
* @Override public void onFailure(Throwable caught) {
|
||||||
|
* GWT.log("Error on loading contacts"); MessageBox.alert("Error",
|
||||||
|
* caught.getMessage(), null); }
|
||||||
|
*
|
||||||
|
* @Override public void onSuccess(List<InfoContactModel> result) {
|
||||||
|
* users.clear(); for (InfoContactModel wsUser : result) { String fullName =
|
||||||
|
* wsUser.getName(); if(users.containsKey(fullName)){ //case of homonimy
|
||||||
|
* fullName = fullName+"_"; users.put(fullName, wsUser); }else
|
||||||
|
* users.put(fullName, wsUser);
|
||||||
|
*
|
||||||
|
* oracle.add(fullName); } } };
|
||||||
*/
|
*/
|
||||||
public void updateSuggestions(List<InfoContactModel> result) {
|
|
||||||
|
|
||||||
oracle.clear();
|
|
||||||
|
|
||||||
for (InfoContactModel wsUser : result) {
|
|
||||||
oracle.add(wsUser.getName());
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private AsyncCallback<List<InfoContactModel>> contacts = new AsyncCallback<List<InfoContactModel>>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
GWT.log("Error on loading contacts");
|
|
||||||
MessageBox.alert("Error", caught.getMessage(), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSuccess(List<InfoContactModel> result) {
|
|
||||||
users.clear();
|
|
||||||
for (InfoContactModel wsUser : result) {
|
|
||||||
String fullName = wsUser.getName();
|
|
||||||
if(users.containsKey(fullName)){ //case of homonimy
|
|
||||||
fullName = fullName+"_";
|
|
||||||
users.put(fullName, wsUser);
|
|
||||||
}else
|
|
||||||
users.put(fullName, wsUser);
|
|
||||||
|
|
||||||
oracle.add(fullName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset item selected.
|
* Reset item selected.
|
||||||
*/
|
*/
|
||||||
public void resetItemSelected(){
|
public void resetItemSelected() {
|
||||||
|
|
||||||
listBullet.clear();
|
listBullet.clear();
|
||||||
itemsSelected.clear();
|
// itemsSelected.clear();
|
||||||
|
users.clear();
|
||||||
ListItem item = new ListItem();
|
ListItem item = new ListItem();
|
||||||
item.add(box);
|
item.add(box);
|
||||||
listBullet.add(item);
|
listBullet.add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the recipient.
|
* Adds the recipient.
|
||||||
*
|
*
|
||||||
* @param fullName the full name
|
* @param fullName
|
||||||
* @param displayRemoveItem the display remove item
|
* the full name
|
||||||
|
* @param displayRemoveItem
|
||||||
|
* the display remove item
|
||||||
*/
|
*/
|
||||||
public void addRecipient(String fullName, boolean displayRemoveItem) {
|
public void addRecipient(InfoContactModel infoContactModel, boolean displayRemoveItem) {
|
||||||
|
|
||||||
if (fullName != null) {
|
if (infoContactModel != null) {
|
||||||
|
|
||||||
TextBox itemBox = new TextBox();
|
TextBox itemBox = new TextBox();
|
||||||
itemBox.setText(fullName);
|
itemBox.setText(infoContactModel.getName());
|
||||||
itemBox.setValue(fullName);
|
itemBox.setValue(infoContactModel.getName());
|
||||||
final ListItem displayItem = new ListItem();
|
final ListItem displayItem = new ListItem();
|
||||||
|
|
||||||
Paragraph p = new Paragraph(fullName);
|
Paragraph p = new Paragraph(infoContactModel.getName());
|
||||||
displayItem.add(p);
|
displayItem.add(p);
|
||||||
|
|
||||||
if(displayRemoveItem){
|
if (displayRemoveItem) {
|
||||||
displayItem.setStyleName("multivalue-panel-token-ws");
|
displayItem.setStyleName("multivalue-panel-token-ws");
|
||||||
p.setRemovable(true);
|
p.setRemovable(true);
|
||||||
Span span = new Span("x");
|
Span span = new Span("x");
|
||||||
|
@ -276,17 +284,17 @@ public class MultiValuePanel extends Composite {
|
||||||
});
|
});
|
||||||
|
|
||||||
displayItem.add(span);
|
displayItem.add(span);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
displayItem.setStyleName("multivalue-panel-token-ws-notselectable");
|
displayItem.setStyleName("multivalue-panel-token-ws-notselectable");
|
||||||
p.setRemovable(false);
|
p.setRemovable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
GWT.log("Adding selected wp item '" + itemBox.getValue());
|
GWT.log("Adding selected wp item '" + itemBox.getValue());
|
||||||
itemsSelected.add(itemBox.getValue());
|
// itemsSelected.add(itemBox.getValue());
|
||||||
GWT.log("Total: " + itemsSelected);
|
// GWT.log("Total: " + itemsSelected);
|
||||||
|
users.put(infoContactModel.getName(), infoContactModel);
|
||||||
|
|
||||||
listBullet.insert(displayItem, listBullet.getWidgetCount()-1);
|
listBullet.insert(displayItem, listBullet.getWidgetCount() - 1);
|
||||||
itemBox.setValue("");
|
itemBox.setValue("");
|
||||||
itemBox.setFocus(true);
|
itemBox.setFocus(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
package org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingServiceAsync;
|
||||||
|
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
||||||
|
|
||||||
|
import com.google.gwt.core.shared.GWT;
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Giancarlo Panichi
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ServerMultiWordSuggestOracle extends MultiWordSuggestOracle {
|
||||||
|
|
||||||
|
private static final int DEFAULT_QUERY_LENGHT = 1;
|
||||||
|
//private int startQueryLength;
|
||||||
|
private ArrayList<InfoContactModelSuggestion> suggestions = new ArrayList<>();
|
||||||
|
//private boolean isMoreSuggestions = false;
|
||||||
|
//private int previousQueryLength = 0;
|
||||||
|
|
||||||
|
public ServerMultiWordSuggestOracle() {
|
||||||
|
this(DEFAULT_QUERY_LENGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServerMultiWordSuggestOracle(int startQueryLength) {
|
||||||
|
super();
|
||||||
|
//this.startQueryLength = startQueryLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void requestSuggestions(final Request request, final Callback callback) {
|
||||||
|
// start the backend call only if the user types in more than
|
||||||
|
// startQueryLength characters.
|
||||||
|
//if (request.getQuery().length() < startQueryLength)
|
||||||
|
// return;
|
||||||
|
// if the user expands the search or a search hasn't been carried out,
|
||||||
|
// call the backend. Otherwise use the existing list
|
||||||
|
//if (isMoreSuggestions || previousQueryLength > request.getQuery().length() || suggestions.size() == 0) {
|
||||||
|
String keyword = request.getQuery();
|
||||||
|
keyword = keyword.toLowerCase();
|
||||||
|
|
||||||
|
WorkspaceSharingServiceAsync.INSTANCE.getUsersByKeyword(keyword,
|
||||||
|
new AsyncCallback<List<InfoContactModel>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(List<InfoContactModel> result) {
|
||||||
|
suggestions.clear();
|
||||||
|
for (int i = 0; i < result.size(); i++) {
|
||||||
|
InfoContactModelSuggestion suggestion = new InfoContactModelSuggestion(result.get(i));
|
||||||
|
suggestions.add(suggestion);
|
||||||
|
}
|
||||||
|
|
||||||
|
MultiWordSuggestOracle.Response response = new MultiWordSuggestOracle.Response(suggestions);
|
||||||
|
// isMoreSuggestions = isMore;
|
||||||
|
|
||||||
|
/*if (result == null || result.isEmpty()) {
|
||||||
|
response.setMoreSuggestions(false);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
int count = result.size() - request.getLimit();
|
||||||
|
if (count > 0) {
|
||||||
|
response.setMoreSuggestionsCount(count);
|
||||||
|
} else {
|
||||||
|
response.setMoreSuggestions(false);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
//previousQueryLength = request.getQuery().length();
|
||||||
|
callback.onSuggestionsReady(request, response);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
GWT.log("Error retrieving users in ServerMultiWordSuggest", caught);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//} else {
|
||||||
|
// super.requestSuggestions(request, callback);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -67,31 +67,31 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
if (hashTestUser == null) {
|
if (hashTestUser == null) {
|
||||||
hashTestUser = new HashMap<String, InfoContactModel>();
|
hashTestUser = new HashMap<String, InfoContactModel>();
|
||||||
|
|
||||||
hashTestUser.put("federico.defaveri",
|
hashTestUser.put("federico.defaveri", new InfoContactModel("federico.defaveri", "federico.defaveri",
|
||||||
new InfoContactModel("federico.defaveri", "federico.defaveri", "Federico de Faveri", false));
|
"Federico de Faveri", "@isti.cnr.it", false));
|
||||||
|
|
||||||
hashTestUser.put("antonio.gioia",
|
hashTestUser.put("antonio.gioia",
|
||||||
new InfoContactModel("antonio.gioia", "antonio.gioia", "Antonio Gioia", false));
|
new InfoContactModel("antonio.gioia", "antonio.gioia", "Antonio Gioia", "@isti.cnr.it", false));
|
||||||
|
|
||||||
hashTestUser.put("fabio.sinibaldi",
|
hashTestUser.put("fabio.sinibaldi", new InfoContactModel("fabio.sinibaldi", "fabio.sinibaldi",
|
||||||
new InfoContactModel("fabio.sinibaldi", "fabio.sinibaldi", "Fabio Sinibaldi", false));
|
"Fabio Sinibaldi", "@isti.cnr.it", false));
|
||||||
|
|
||||||
hashTestUser.put("pasquale.pagano",
|
hashTestUser.put("pasquale.pagano", new InfoContactModel("pasquale.pagano", "pasquale.pagano",
|
||||||
new InfoContactModel("pasquale.pagano", "pasquale.pagano", "Pasquale Pagano", false));
|
"Pasquale Pagano", "@isti.cnr.it", false));
|
||||||
|
|
||||||
hashTestUser.put("francesco.mangiacrapa", new InfoContactModel("francesco.mangiacrapa",
|
hashTestUser.put("francesco.mangiacrapa", new InfoContactModel("francesco.mangiacrapa",
|
||||||
"francesco.mangiacrapa", "Francesco Mangiacrapa", false));
|
"francesco.mangiacrapa", "Francesco Mangiacrapa", "@isti.cnr.it", false));
|
||||||
|
|
||||||
hashTestUser.put("massimiliano.assante", new InfoContactModel("massimiliano.assante",
|
hashTestUser.put("massimiliano.assante", new InfoContactModel("massimiliano.assante",
|
||||||
"massimiliano.assante", "Massimiliano Assante", false));
|
"massimiliano.assante", "Massimiliano Assante", "@isti.cnr.it", false));
|
||||||
|
|
||||||
hashTestUser.put("leonardo.candela",
|
hashTestUser.put("leonardo.candela", new InfoContactModel("leonardo.candela", "leonardo.candela",
|
||||||
new InfoContactModel("leonardo.candela", "leonardo.candela", "Leonardo Candela", false));
|
"Leonardo Candela", "@isti.cnr.it", false));
|
||||||
|
|
||||||
hashTestUser.put("valentina.marioli",
|
hashTestUser.put("valentina.marioli", new InfoContactModel("valentina.marioli", "valentina.marioli",
|
||||||
new InfoContactModel("valentina.marioli", "valentina.marioli", "Valentina Marioli", false));
|
"Valentina Marioli", "@isti.cnr.it", false));
|
||||||
|
|
||||||
hashTestUser.put("devVRE", new InfoContactModel("devVRE", "devVRE", "devVRE", true));
|
hashTestUser.put("devVRE", new InfoContactModel("devVRE", "devVRE", "devVRE", "", true));
|
||||||
|
|
||||||
// hashTestUser.put(WsUtil.TEST_USER.toString(),
|
// hashTestUser.put(WsUtil.TEST_USER.toString(),
|
||||||
// new InfoContactModel(
|
// new InfoContactModel(
|
||||||
|
@ -166,7 +166,7 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
logger.warn("Skipping group with null or empty name " + group);
|
logger.warn("Skipping group with null or empty name " + group);
|
||||||
else {
|
else {
|
||||||
InfoContactModel contact = new InfoContactModel(group.getGroupName(), group.getGroupName(), groupDN,
|
InfoContactModel contact = new InfoContactModel(group.getGroupName(), group.getGroupName(), groupDN,
|
||||||
true);
|
"", true);
|
||||||
logger.trace("Adding group " + contact);
|
logger.trace("Adding group " + contact);
|
||||||
listContactsModel.add(contact);
|
listContactsModel.add(contact);
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
logger.warn("Skipping group with null or empty name " + group);
|
logger.warn("Skipping group with null or empty name " + group);
|
||||||
else
|
else
|
||||||
listContactsModel.add(new InfoContactModel(group.getGroupName(), group.getGroupName(),
|
listContactsModel.add(new InfoContactModel(group.getGroupName(), group.getGroupName(),
|
||||||
group.getGroupName(), true));
|
group.getGroupName(), "", true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,6 +249,18 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
return listContactsModel;
|
return listContactsModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* utility method extract the @domain.com from an email address
|
||||||
|
* return @unknown-domain in case of no emails
|
||||||
|
*/
|
||||||
|
private String extractDomainFromEmail(String email) {
|
||||||
|
int index = email.indexOf('@');
|
||||||
|
if (index > 0)
|
||||||
|
return email.substring(index);
|
||||||
|
else
|
||||||
|
return "@unknown-domain";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param info
|
* @param info
|
||||||
|
@ -275,8 +287,8 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
String fullName = userModel.getFullname();
|
String fullName = userModel.getFullname();
|
||||||
|
|
||||||
if (fullName != null && !fullName.isEmpty())
|
if (fullName != null && !fullName.isEmpty())
|
||||||
listContactsModel.add(
|
listContactsModel.add(new InfoContactModel(userModel.getUserId() + "", userModel.getUsername(),
|
||||||
new InfoContactModel(userModel.getUserId() + "", userModel.getUsername(), fullName, false));
|
fullName, extractDomainFromEmail(userModel.getEmail()), false));
|
||||||
else
|
else
|
||||||
logger.trace("buildGXTListContactsModel is not returning user: " + userModel.getUsername()
|
logger.trace("buildGXTListContactsModel is not returning user: " + userModel.getUsername()
|
||||||
+ "because name is null or empty");
|
+ "because name is null or empty");
|
||||||
|
@ -285,8 +297,7 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
|
|
||||||
return listContactsModel;
|
return listContactsModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param info
|
* @param info
|
||||||
|
@ -295,7 +306,8 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* Error
|
* Error
|
||||||
*/
|
*/
|
||||||
public List<InfoContactModel> buildGXTListContactsModelFromUserModel(PortalContextInfo info,GGroup gGroup) throws Exception {
|
public List<InfoContactModel> buildGXTListContactsModelFromUserModel(PortalContextInfo info, GGroup gGroup)
|
||||||
|
throws Exception {
|
||||||
|
|
||||||
List<GCubeUser> listUsers = new LiferayUserManager().listUsersByGroup(gGroup.getGroupId());
|
List<GCubeUser> listUsers = new LiferayUserManager().listUsersByGroup(gGroup.getGroupId());
|
||||||
|
|
||||||
|
@ -313,8 +325,8 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
String fullName = userModel.getFullname();
|
String fullName = userModel.getFullname();
|
||||||
|
|
||||||
if (fullName != null && !fullName.isEmpty())
|
if (fullName != null && !fullName.isEmpty())
|
||||||
listContactsModel.add(
|
listContactsModel.add(new InfoContactModel(userModel.getUserId() + "", userModel.getUsername(),
|
||||||
new InfoContactModel(userModel.getUserId() + "", userModel.getUsername(), fullName, false));
|
fullName, extractDomainFromEmail(userModel.getEmail()), false));
|
||||||
else
|
else
|
||||||
logger.trace("buildGXTListContactsModel is not returning user: " + userModel.getUsername()
|
logger.trace("buildGXTListContactsModel is not returning user: " + userModel.getUsername()
|
||||||
+ "because name is null or empty");
|
+ "because name is null or empty");
|
||||||
|
@ -324,7 +336,6 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
return listContactsModel;
|
return listContactsModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ArrayList<GGroup> getVREList(PortalContextInfo info) throws Exception {
|
public ArrayList<GGroup> getVREList(PortalContextInfo info) throws Exception {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -362,14 +373,16 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
List<InfoContactModel> listInfoContactModel = new ArrayList<>();
|
List<InfoContactModel> listInfoContactModel = new ArrayList<>();
|
||||||
UserManager userManager = new LiferayUserManager();
|
UserManager userManager = new LiferayUserManager();
|
||||||
List<GCubeUser> users = userManager.searchUsersByGroup(keyword, info.getCurrGroupId());
|
List<GCubeUser> users = userManager.searchUsersByGroup(keyword, info.getCurrGroupId());
|
||||||
for (GCubeUser user : users) {
|
|
||||||
|
for (int i = 0; i < users.size() && i < 30; i++) {
|
||||||
|
GCubeUser user = users.get(i);
|
||||||
InfoContactModel icm = new InfoContactModel(String.valueOf(user.getUserId()), user.getUsername(),
|
InfoContactModel icm = new InfoContactModel(String.valueOf(user.getUserId()), user.getUsername(),
|
||||||
user.getFullname(), false);
|
user.getFullname(), extractDomainFromEmail(user.getEmail()), false);
|
||||||
listInfoContactModel.add(icm);
|
listInfoContactModel.add(icm);
|
||||||
}
|
}
|
||||||
return listInfoContactModel;
|
return listInfoContactModel;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error retrieving the users by keyword: "+e.getLocalizedMessage(), e);
|
logger.error("Error retrieving the users by keyword: " + e.getLocalizedMessage(), e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -408,7 +421,7 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
logger.warn("Contact login is null, return empty");
|
logger.warn("Contact login is null, return empty");
|
||||||
portalLogin = "";
|
portalLogin = "";
|
||||||
}
|
}
|
||||||
return new InfoContactModel(portalLogin, portalLogin, UserUtil.getUserFullName(portalLogin), false);
|
return new InfoContactModel(portalLogin, portalLogin, UserUtil.getUserFullName(portalLogin), "", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -436,7 +449,7 @@ public class GWTWorkspaceSharingBuilder {
|
||||||
groupName = groupLogin;
|
groupName = groupLogin;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new InfoContactModel(groupLogin, groupLogin, groupName, true);
|
return new InfoContactModel(groupLogin, groupLogin, groupName, "", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -176,7 +176,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
public List<InfoContactModel> getUsersByKeyword(String keyword) throws Exception {
|
public List<InfoContactModel> getUsersByKeyword(String keyword) throws Exception {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logger.info("Call getUsersByKeyword(): keyword="+keyword);
|
logger.info("Call getUsersByKeyword(): keyword=" + keyword);
|
||||||
|
|
||||||
PortalContextInfo info = WsUtil.getPortalContext(this.getThreadLocalRequest());
|
PortalContextInfo info = WsUtil.getPortalContext(this.getThreadLocalRequest());
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
throw new Exception("Error retrieving list of contacts!", e);
|
throw new Exception("Error retrieving list of contacts!", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<GGroup> getVREList() throws Exception {
|
public List<GGroup> getVREList() throws Exception {
|
||||||
try {
|
try {
|
||||||
|
@ -208,13 +208,12 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
throw new Exception("Error retrieving VRE List!", e);
|
throw new Exception("Error retrieving VRE List!", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<InfoContactModel> getAllContactsByVRE(GGroup gGroup) throws Exception {
|
public List<InfoContactModel> getAllContactsByVRE(GGroup gGroup) throws Exception {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logger.info("Call getAllContactsByVRE(): "+gGroup);
|
logger.info("Call getAllContactsByVRE(): " + gGroup);
|
||||||
|
|
||||||
if (isTestMode()) {
|
if (isTestMode()) {
|
||||||
logger.debug("WORKSPACE PORTLET IS IN TEST MODE - RETURN TEST USERS AND GROUPS");
|
logger.debug("WORKSPACE PORTLET IS IN TEST MODE - RETURN TEST USERS AND GROUPS");
|
||||||
|
@ -231,7 +230,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
|
|
||||||
GWTWorkspaceSharingBuilder builder = new GWTWorkspaceSharingBuilder();
|
GWTWorkspaceSharingBuilder builder = new GWTWorkspaceSharingBuilder();
|
||||||
|
|
||||||
List<InfoContactModel> listContactsModel = builder.buildGXTListContactsModelFromUserModel(info,gGroup);
|
List<InfoContactModel> listContactsModel = builder.buildGXTListContactsModelFromUserModel(info, gGroup);
|
||||||
|
|
||||||
// listContactsModel.addAll(builder.getGXTListContactsModelFromVOs(info));
|
// listContactsModel.addAll(builder.getGXTListContactsModelFromVOs(info));
|
||||||
|
|
||||||
|
@ -244,7 +243,6 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
@ -294,6 +292,18 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* utility method extract the @domain.com from an email address
|
||||||
|
* return @unknown-domain in case of no emails
|
||||||
|
*/
|
||||||
|
private String extractDomainFromEmail(String email) {
|
||||||
|
int index = email.indexOf('@');
|
||||||
|
if (index > 0)
|
||||||
|
return email.substring(index);
|
||||||
|
else
|
||||||
|
return "@unknown-domain";
|
||||||
|
}
|
||||||
|
|
||||||
private List<InfoContactModel> retrieveUsersListFromSharedFolder(SharedFolder sharedFolder) throws Exception {
|
private List<InfoContactModel> retrieveUsersListFromSharedFolder(SharedFolder sharedFolder) throws Exception {
|
||||||
Metadata metadata = sharedFolder.getUsers();
|
Metadata metadata = sharedFolder.getUsers();
|
||||||
if (metadata != null) {
|
if (metadata != null) {
|
||||||
|
@ -311,7 +321,8 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
logger.warn("Invalid info for user " + username, e);
|
logger.warn("Invalid info for user " + username, e);
|
||||||
}
|
}
|
||||||
if (curr != null && curr.getFullname() != null && !curr.getFullname().isEmpty()) {
|
if (curr != null && curr.getFullname() != null && !curr.getFullname().isEmpty()) {
|
||||||
InfoContactModel userInfo = new InfoContactModel(username, username, curr.getFullname(), false);
|
InfoContactModel userInfo = new InfoContactModel(username, username, curr.getFullname(),
|
||||||
|
extractDomainFromEmail(curr.getEmail()), false);
|
||||||
listShared.add(userInfo);
|
listShared.add(userInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -362,7 +373,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.debug("Owner not found from user model!");
|
logger.debug("Owner not found from user model!");
|
||||||
return new InfoContactModel(item.getOwner(), item.getOwner(), item.getOwner(), false);
|
return new InfoContactModel(item.getOwner(), item.getOwner(), item.getOwner(), "", false);
|
||||||
} else {
|
} else {
|
||||||
logger.debug("Owner not found from item");
|
logger.debug("Owner not found from item");
|
||||||
return new InfoContactModel();
|
return new InfoContactModel();
|
||||||
|
@ -1114,7 +1125,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
logger.info("Unshared folded for users: " + users);
|
logger.info("Unshared folded for users: " + users);
|
||||||
ArrayList<InfoContactModel> listContacts = new ArrayList<>();
|
ArrayList<InfoContactModel> listContacts = new ArrayList<>();
|
||||||
for (String key : users) {
|
for (String key : users) {
|
||||||
InfoContactModel contact = new InfoContactModel(key, key, key, false);
|
InfoContactModel contact = new InfoContactModel(key, key, key, "",false);
|
||||||
listContacts.add(contact);
|
listContacts.add(contact);
|
||||||
}
|
}
|
||||||
NotificationsProducer np = getNotificationProducer(
|
NotificationsProducer np = getNotificationProducer(
|
||||||
|
|
|
@ -6,50 +6,34 @@ import java.util.Comparator;
|
||||||
import com.extjs.gxt.ui.client.data.BaseModelData;
|
import com.extjs.gxt.ui.client.data.BaseModelData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Francesco Mangiacrapa
|
* @author Francesco Mangiacrapa
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class InfoContactModel extends BaseModelData implements Serializable, Comparable<InfoContactModel> {
|
public class InfoContactModel extends BaseModelData implements Serializable, Comparable<InfoContactModel> {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -6158514541724213534L;
|
private static final long serialVersionUID = -6158514541724213534L;
|
||||||
|
|
||||||
protected static final String ID = "id";
|
protected static final String ID = "id";
|
||||||
public static final String FULLNAME = "fullname";
|
public static final String FULLNAME = "fullname";
|
||||||
public static final String LOGIN = "login";
|
public static final String LOGIN = "login";
|
||||||
|
public static final String EMAIL_DOMAIN = "emailDomain";
|
||||||
public static final String ISGROUP = "isgroup";
|
public static final String ISGROUP = "isgroup";
|
||||||
|
|
||||||
private CredentialModel referenceCredential;
|
private CredentialModel referenceCredential;
|
||||||
|
|
||||||
|
public InfoContactModel() {
|
||||||
|
}
|
||||||
|
|
||||||
public InfoContactModel() {}
|
public InfoContactModel(String id, String login, String fullName, String emailDomain, boolean isGroup) {
|
||||||
|
|
||||||
public InfoContactModel(String id, String login, String fullName, boolean isGroup) {
|
|
||||||
setId(id);
|
setId(id);
|
||||||
setLogin(login);
|
setLogin(login);
|
||||||
setName(fullName);
|
setName(fullName);
|
||||||
|
setEmailDomain(emailDomain);
|
||||||
setIsGroup(isGroup);
|
setIsGroup(isGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsGroup(boolean isGroup){
|
|
||||||
set(ISGROUP, isGroup);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean isGroup(){
|
|
||||||
return (Boolean) get(ISGROUP);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
set(FULLNAME,name);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName(){
|
|
||||||
return get(FULLNAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return get(ID);
|
return get(ID);
|
||||||
|
@ -67,7 +51,31 @@ public class InfoContactModel extends BaseModelData implements Serializable, Com
|
||||||
set(LOGIN, login);
|
set(LOGIN, login);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return get(FULLNAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
set(FULLNAME, name);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmailDomain() {
|
||||||
|
return (String) get(EMAIL_DOMAIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmailDomain(String emailDomain) {
|
||||||
|
set(EMAIL_DOMAIN, emailDomain);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean isGroup() {
|
||||||
|
return (Boolean) get(ISGROUP);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsGroup(boolean isGroup) {
|
||||||
|
set(ISGROUP, isGroup);
|
||||||
|
}
|
||||||
|
|
||||||
public static Comparator<InfoContactModel> COMPARATORLOGINS = new Comparator<InfoContactModel>() {
|
public static Comparator<InfoContactModel> COMPARATORLOGINS = new Comparator<InfoContactModel>() {
|
||||||
// This is where the sorting happens.
|
// This is where the sorting happens.
|
||||||
public int compare(InfoContactModel o1, InfoContactModel o2) {
|
public int compare(InfoContactModel o1, InfoContactModel o2) {
|
||||||
|
@ -75,7 +83,6 @@ public class InfoContactModel extends BaseModelData implements Serializable, Com
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the referenceCredential
|
* @return the referenceCredential
|
||||||
*/
|
*/
|
||||||
|
@ -84,45 +91,39 @@ public class InfoContactModel extends BaseModelData implements Serializable, Com
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param referenceCredential the referenceCredential to set
|
* @param referenceCredential
|
||||||
|
* the referenceCredential to set
|
||||||
*/
|
*/
|
||||||
public void setReferenceCredential(CredentialModel referenceCredential) {
|
public void setReferenceCredential(CredentialModel referenceCredential) {
|
||||||
this.referenceCredential = referenceCredential;
|
this.referenceCredential = referenceCredential;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
/* (non-Javadoc)
|
*
|
||||||
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(InfoContactModel o) {
|
public int compareTo(InfoContactModel o) {
|
||||||
return InfoContactModel.COMPARATORLOGINS.compare(this, o);
|
return InfoContactModel.COMPARATORLOGINS.compare(this, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
* @see java.lang.Object#equals(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
int compare = compareTo((InfoContactModel) obj);
|
int compare = compareTo((InfoContactModel) obj);
|
||||||
return compare == 0? true:false;
|
return compare == 0 ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder();
|
return "InfoContactModel [getId()=" + getId() + ", getLogin()=" + getLogin() + ", getName()=" + getName()
|
||||||
builder.append("InfoContactModel [isGroup()=");
|
+ ", getEmailDomain()=" + getEmailDomain() + ", isGroup()=" + isGroup() + ", getReferenceCredential()="
|
||||||
builder.append(isGroup());
|
+ getReferenceCredential() + "]";
|
||||||
builder.append(", getName()=");
|
|
||||||
builder.append(getName());
|
|
||||||
builder.append(", getId()=");
|
|
||||||
builder.append(getId());
|
|
||||||
builder.append(", getLogin()=");
|
|
||||||
builder.append(getLogin());
|
|
||||||
builder.append(", getReferenceCredential()=");
|
|
||||||
builder.append(getReferenceCredential());
|
|
||||||
builder.append("]");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue