3277: Workspace Sharing Widget enhancement in order to display short VREs name

Task-Url: https://support.d4science.org/issues/3277

Updated pom version at 1.6.0
Realized solution to implement the above task

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-sharing-widget@128085 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2016-04-14 13:16:09 +00:00
parent 3db6e37121
commit 153942ce28
10 changed files with 857 additions and 620 deletions

View File

@ -14,7 +14,7 @@
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>workspace-sharing-widget</artifactId>
<packaging>jar</packaging>
<version>1.5.1-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
<name>gCube Workspace Sharing Widget</name>
<description>
gCube Workspace Sharing Widget allows users to share gCube Workspace items

View File

@ -107,13 +107,9 @@ public class WorkspaceSmartSharingController {
private void updateSharingDialog(){
smartShare.unmask();
smartShare.updateSharingDialog(fileModel, listAlreadySharedContact);
// dialogShareItem.show();
smartShare.layout();
}
/**
*
* @return SmartShare An extension of gxt dialog 2.2.5

View File

@ -348,16 +348,12 @@ public class DialogShareWItem extends Dialog {
List<InfoContactModel> exclusiveContacts = userStore.getExclusiveContactsFromAllContact(suggestPanel.getSelectedUser());
multiDrag.addSourceContacts(exclusiveContacts);
for (InfoContactModel infoContactModel : suggestPanel.getSelectedUser()) {
if(!listAlreadyShared.contains(infoContactModel))
multiDrag.addTargetContact(infoContactModel);
}
multiDrag.addAlreadySharedContacts(suggestPanel.getSelectedUser());
// multiDrag.addTargetContacts(suggestPanel.getSelectedUser());
dialog.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override

View File

@ -26,6 +26,7 @@ import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
@ -34,9 +35,10 @@ import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Label;
/**
* The Class SmartShare.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @Mar 3, 2014
*
*/
public class SmartShare extends Dialog implements SmartDialogInterface{
@ -49,7 +51,7 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
private boolean readGroupsFromPortal;
/**
* SmartShare base constructor by default does not retrieve groupss
* SmartShare base constructor by default does not retrieve groupss.
*/
public SmartShare() {
this(false, false);
@ -57,10 +59,10 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
/**
* Instantiates a new smart share.
*
* @param readGroupsFromHL - if true read group names from HL
* @param readGroupsFromPortal - if true read group names from Portal (as VRE)
*
*/
public SmartShare(boolean readGroupsFromHL, boolean readGroupsFromPortal) {
this.readGroupsFromHL = readGroupsFromHL;
@ -69,13 +71,9 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
initLayout();
}
private List<InfoContactModel> listAlreadyShared = new ArrayList<InfoContactModel>(){
/**
*
*/
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = -610980920163628336L;
/**
* Compare Login
@ -92,19 +90,16 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
if (contact.getName().compareTo(listAlreadyShared.get(i).getName())==0)
return true;
}
return false;
};
};
/**
* Use to modify a shared folder or share an existing folder
* @param fileModel
* @param type
* Use to modify a shared folder or share an existing folder.
*
* @param fileModel the file model
* @param listAlreadySharedContact the list already shared contact
*/
public void updateSharingDialog(FileModel fileModel, List<CredentialModel> listAlreadySharedContact){
@ -154,7 +149,6 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
flexTable.setWidget(1, 0, labelAddMore);
flexTable.setWidget(1, 1, buttonMultiDrag);
if(listAlreadySharedContact!=null && listAlreadySharedContact.size()>0){
userStore.getInfoContactModelsFromCredential(listAlreadySharedContact, new AsyncCallback<List<InfoContactModel>>() {
@ -162,46 +156,43 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
@Override
public void onSuccess(List<InfoContactModel> result) {
for (InfoContactModel infoContactModel : result) {
if(infoContactModel.getName()!=null){
String name = infoContactModel.getName()!=null && !infoContactModel.getName().isEmpty()?infoContactModel.getName():infoContactModel.getLogin();
listAlreadyShared.add(infoContactModel);
suggestPanel.addRecipient(infoContactModel.getName(),false);
suggestPanel.addRecipient(name,false);
layout();
}
}
lc.unmask();
lc.layout();
layout();
}
@Override
public void onFailure(Throwable caught) {
lc.unmask();
}
});
}
lc.add(flexTable);
setFocusWidget(suggestPanel.getBox());
add(txtName);
// add(txtOwner);
add(lc);
addListeners();
}
/**
* Gets the file to share.
*
* @return
* @return the file to share
*/
public FileModel getFileToShare() {
return fileToShare;
}
/**
* Inits the layout.
*/
private void initLayout(){
FormLayout layout = new FormLayout();
layout.setLabelWidth(90);
@ -220,6 +211,7 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
/**
* Gets the shared list users.
*
* @return the selected contacts (as InfoContactModel)
*/
@ -239,6 +231,7 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
/**
* Gets the shared list users credential.
*
* @return the selected contacts (as CredentialModel)
*/
@ -257,6 +250,12 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
return toReturn;
}
/**
* Gets the credential model from info contact model.
*
* @param infoContact the info contact
* @return the credential model from info contact model
*/
private CredentialModel getCredentialModelFromInfoContactModel(InfoContactModel infoContact){
if(infoContact==null)
@ -272,6 +271,9 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
}
/**
* Adds the listeners.
*/
public void addListeners(){
this.getButtonById(Dialog.CANCEL).addSelectionListener(new SelectionListener<ButtonEvent>() {
@ -299,20 +301,16 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
final DialogMultiDragContact dialog = new DialogMultiDragContact(true,true);
final MultiDragContact multiDrag = dialog.getMultiDrag();
dialog.show();
printSelectedUser();
List<InfoContactModel> exclusiveContacts = userStore.getExclusiveContactsFromAllContact(suggestPanel.getSelectedUser());
multiDrag.addSourceContacts(exclusiveContacts);
for (InfoContactModel infoContactModel : suggestPanel.getSelectedUser()) {
if(!listAlreadyShared.contains(infoContactModel))
multiDrag.addTargetContact(infoContactModel);
}
multiDrag.addAlreadySharedContacts(suggestPanel.getSelectedUser());
// multiDrag.addTargetContacts(suggestPanel.getSelectedUser());
dialog.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
@ -332,13 +330,19 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
suggestPanel.boxSetFocus();
// printSelectedUser();
}
});
}
});
}
/**
* List already shared contains.
*
* @param contact the contact
* @return true, if successful
*/
private boolean listAlreadySharedContains(InfoContactModel contact){
if(contact==null)
@ -358,13 +362,19 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
}
//DEBUG
/**
* Prints the selected user.
*/
private void printSelectedUser(){
System.out.println("SELETECTED USERS: ");
GWT.log("SELETECTED USERS: ");
for (InfoContactModel contact : suggestPanel.getSelectedUser())
System.out.println(contact);
GWT.log(contact.toString());
}
/**
* Inits the suggest contacts.
*/
private void initSuggestContacts(){
suggestPanel.resetItemSelected();
@ -376,25 +386,41 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
}
/**
* Sets the as error.
*
* @param message the new as error
*/
public void setAsError(String message){
enableFormDialog(false);
this.add(new Html("<br/> <p style=\"color:red; font-family:verdana, arial; font-size:14px;\">"+message+"</p>"));
this.layout();
}
/**
* Enable form dialog.
*
* @param bool the bool
*/
private void enableFormDialog(boolean bool){
getButtonById(Dialog.OK).setEnabled(bool);
buttonMultiDrag.setEnabled(bool);
}
/**
* Gets the name.
*
* @return the name
*/
public String getName() {
return txtName.getValue();
}
/**
* Checks if is valid form.
*
* @param displayAlert in case of error
* @return
* @return true, if is valid form
*/
public boolean isValidForm(boolean displayAlert){
@ -417,11 +443,21 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
}
/**
* Checks if is read groups from hl.
*
* @return true, if is read groups from hl
*/
public boolean isReadGroupsFromHL() {
return readGroupsFromHL;
}
/**
* Checks if is read groups from portal.
*
* @return true, if is read groups from portal
*/
public boolean isReadGroupsFromPortal() {
return readGroupsFromPortal;
}

View File

@ -25,10 +25,10 @@ import com.google.gwt.user.client.ui.SuggestOracle;
import com.google.gwt.user.client.ui.TextBox;
/**
* The Class MultiValuePanel.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @Feb 25, 2014
*
*/
public class MultiValuePanel extends Composite {
@ -36,17 +36,20 @@ public class MultiValuePanel extends Composite {
private List<String> itemsSelected = new ArrayList<String>();
FlowPanel panel = new FlowPanel();
// private HandlerManager eventBus;
private HashMap<String, InfoContactModel> users = new HashMap<String, InfoContactModel>();
private HashMap<String, InfoContactModel> users = new HashMap<String, InfoContactModel>(); //AN HAST FULLNAME - INFOCONTACTMODEL
private BulletList listBullet = new BulletList();
private SuggestBox box;
private ContactFetcher userFetch;
private MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
private MultiWordSuggestOracle oracle = new MultiWordSuggestOracle(); //ORACLE OF FULL NAMES
private boolean readGroupsFromHL;
private boolean readGroupsFromPortal;
/**
* Instantiates a new multi value panel.
*
* @param userFetch the ContactFetcher
* @param readGroupsFromHL the read groups from hl
* @param readGroupsFromPortal the read groups from portal
*/
public MultiValuePanel(ContactFetcher userFetch, boolean readGroupsFromHL, boolean readGroupsFromPortal) {
this.userFetch = userFetch;
@ -76,7 +79,7 @@ public class MultiValuePanel extends Composite {
if(li.getWidget(0) instanceof Paragraph){
Paragraph p = (Paragraph) li.getWidget(0);
GWT.log("p "+p.getText() +" is removable : " + p.isRemovable());
if (itemsSelected.contains(p.getText()) && (p.isRemovable()==true)) {
if (itemsSelected.contains(p.getText()) && p.isRemovable()==true) {
itemsSelected.remove(p.getText());
GWT.log("Removing selected item: " + p.getText() + "'");
listBullet.remove(li);
@ -99,22 +102,30 @@ public class MultiValuePanel extends Composite {
panel.add(listBullet);
box.getElement().setId("suggestion_box"); //needed for the focus on click
panel.getElement().setAttribute("onclick", "document.getElementById('suggestion_box').focus()");
// box.setFocus(true);
}
/**
* Box set focus.
*/
public void boxSetFocus(){
box.getElement().focus();
box.setFocus(true);
// panel.getElement().setAttribute("onclick", "document.getElementById('suggestion_box').focus()");
}
/**
* Gets the flow panel.
*
* @return the flow panel
*/
public FlowPanel getFlowPanel(){
return panel;
}
/**
* actually insert the contact in the flow panel
* @param itemBox
* @param list
* actually insert the contact in the flow panel.
*
* @param itemBox the item box
* @param list the list
*/
private void chosenContactItem(final TextBox itemBox, final BulletList list) {
if (itemBox.getValue() != null && !"".equals(itemBox.getValue().trim())) {
@ -142,7 +153,9 @@ public class MultiValuePanel extends Composite {
itemBox.setFocus(true);
}
}
/**
* Gets the selected user.
*
* @return the selected contacts (user logins e.g. pino.pini)
*/
@ -151,9 +164,10 @@ public class MultiValuePanel extends Composite {
return new ArrayList<InfoContactModel>();
else {
List<InfoContactModel> toReturn = new ArrayList<InfoContactModel>();
for (String login : itemsSelected) {
InfoContactModel wsuser = users.get(login);
// GWT.log("Selected User: "+itemsSelected);
// GWT.log("users: "+users);
for (String fullName : itemsSelected) {
InfoContactModel wsuser = users.get(fullName);
if(wsuser!= null && !toReturn.contains(wsuser))
toReturn.add(wsuser);
}
@ -161,6 +175,12 @@ public class MultiValuePanel extends Composite {
}
}
/**
* Removes the list item.
*
* @param displayItem the display item
* @param list the list
*/
private void removeListItem(ListItem displayItem, BulletList list) {
GWT.log("Removing: " + displayItem.getWidget(0).getElement().getInnerHTML(), null);
itemsSelected.remove(displayItem.getWidget(0).getElement().getInnerHTML());
@ -168,17 +188,21 @@ public class MultiValuePanel extends Composite {
}
/**
* Gets the suggestions.
*
* @return names of possible contacts
*/
private MultiWordSuggestOracle getSuggestions() {
userFetch.getListContact(contacts, false,readGroupsFromHL,readGroupsFromPortal);
return oracle;
}
/**
* Update suggestions.
*
* @param result the result
*/
public void updateSuggestions(List<InfoContactModel> result) {
oracle.clear();
@ -192,7 +216,6 @@ public class MultiValuePanel extends Composite {
private AsyncCallback<List<InfoContactModel>> contacts = new AsyncCallback<List<InfoContactModel>>() {
@Override
public void onFailure(Throwable caught) {
GWT.log("Error on loading contacts");
@ -201,16 +224,23 @@ public class MultiValuePanel extends Composite {
@Override
public void onSuccess(List<InfoContactModel> result) {
users.clear();
for (InfoContactModel wsUser : result) {
oracle.add(wsUser.getName());
users.put(wsUser.getName(), wsUser);
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.
*/
public void resetItemSelected(){
listBullet.clear();
@ -222,9 +252,10 @@ public class MultiValuePanel extends Composite {
/**
* Adds the recipient.
*
* @param contact
* @param displayRemoveItem
* @param fullName the full name
* @param displayRemoveItem the display remove item
*/
public void addRecipient(String fullName, boolean displayRemoveItem) {
@ -255,8 +286,6 @@ public class MultiValuePanel extends Composite {
p.setRemovable(false);
}
GWT.log("Adding selected wp item '" + itemBox.getValue());
itemsSelected.add(itemBox.getValue());
GWT.log("Total: " + itemsSelected);
@ -268,10 +297,18 @@ public class MultiValuePanel extends Composite {
}
/**
* Clear list.
*/
public void clearList() {
listBullet.clear();
}
/**
* Gets the box.
*
* @return the box
*/
public SuggestBox getBox() {
return box;

View File

@ -35,9 +35,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class GWTWorkspaceSharingBuilder.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @Feb 25, 2014
*
*/
public class GWTWorkspaceSharingBuilder {
@ -48,9 +49,9 @@ public class GWTWorkspaceSharingBuilder {
protected static HashMap<String, InfoContactModel> hashTestUser = null;
/**
* Used in test mode
* Used in test mode.
*
* @return
* @return the hash test users
*/
public static HashMap<String, InfoContactModel> getHashTestUsers() {
@ -103,17 +104,20 @@ public class GWTWorkspaceSharingBuilder {
}
/**
* @param infoContactModel
* Sets the user logged.
*
* @param infoContactModel the new user logged
*/
public void setUserLogged(InfoContactModel infoContactModel) {
this.userLogged = infoContactModel;
}
/**
* Builds the gxt list contacts model from gcube group.
*
* @param list
* @return
* @throws InternalErrorException
* @param list the list
* @return the list
* @throws InternalErrorException the internal error exception
*/
public List<InfoContactModel> buildGXTListContactsModelFromGcubeGroup(List<GCubeGroup> list) throws InternalErrorException {
@ -161,11 +165,12 @@ public class GWTWorkspaceSharingBuilder {
}
/**
* Builds the gxt list contacts model from v os.
*
* @param voPath
* @param list
* @return
* @throws InternalErrorException
* @param listVO the list vo
* @param voPath the vo path
* @return the list
* @throws InternalErrorException the internal error exception
*/
public List<InfoContactModel> buildGXTListContactsModelFromVOs(List<VO> listVO, String voPath) throws InternalErrorException {
@ -201,9 +206,10 @@ public class GWTWorkspaceSharingBuilder {
if(vre.getName()!=null || !vre.getName().isEmpty()){
String groupId = voPath+vre.getName();
InfoContactModel contact = new InfoContactModel(groupId, groupId, vre.getName(), true);
logger.trace("Adding group contact " + contact);
listContactsModel.add(contact);
logger.trace("adding contact groupId: "+groupId +" VRE name: "+vre.getName());
// InfoContactModel contact = new InfoContactModel(groupId, groupId, vre.getName(), true);
// logger.trace("Adding group contact " + contact);
// listContactsModel.add(contact);
}
}
}else
@ -216,6 +222,13 @@ public class GWTWorkspaceSharingBuilder {
return listContactsModel;
}
/**
* Builds the gxt list contacts model from user model.
*
* @param listUsers the list users
* @return the list
* @throws InternalErrorException the internal error exception
*/
public List<InfoContactModel> buildGXTListContactsModelFromUserModel(
List<UserModel> listUsers) throws InternalErrorException {
@ -247,9 +260,10 @@ public class GWTWorkspaceSharingBuilder {
}
/**
* Builds the gxt info contacts from portal logins.
*
* @param listPortalLogin
* @return
* @param listPortalLogin the list portal login
* @return the list
*/
public List<InfoContactModel> buildGxtInfoContactsFromPortalLogins(List<String> listPortalLogin) {
@ -261,27 +275,53 @@ public class GWTWorkspaceSharingBuilder {
}
/**
* Builds the gxt info contact from portal login.
*
* @param portalLogin
* @return
* @param portalLogin the portal login
* @return the info contact model
*/
protected InfoContactModel buildGxtInfoContactFromPortalLogin(String portalLogin) {
if (portalLogin == null) {
logger.warn("portal login is null, return empty");
logger.warn("Contact login is null, return empty");
portalLogin = "";
}
// TODO ISGROUP
return new InfoContactModel(portalLogin, portalLogin,UserUtil.getUserFullName(portalLogin), false);
}
/**
* Builds the gxt info contact from portal group.
*
* @param grouoLogin the grouo login
* @return the info contact model
*/
protected InfoContactModel buildGxtInfoContactFromPortalGroup(String grouoLogin) {
String groupName = "";
if (grouoLogin == null) {
logger.warn("GroupLogin is null, return empty");
grouoLogin = "";
}
//RECOVERING VRE NAME
if(grouoLogin.contains("/")){
int start = grouoLogin.lastIndexOf("/");
int end = grouoLogin.length();
if(start<end)
groupName = grouoLogin.substring(start+1, end);
else
groupName = grouoLogin;
}
return new InfoContactModel(grouoLogin, grouoLogin, groupName , true);
}
/**
* Used in test mode
* Used in test mode.
*
* @param listPortalLogin
* @return
* @param listPortalLogin the list portal login
* @return the list
*/
protected List<InfoContactModel> buildGxtInfoContactFromPortalLoginTestMode(List<String> listPortalLogin) {
@ -295,10 +335,11 @@ public class GWTWorkspaceSharingBuilder {
}
/**
* Builds the gxt info contact model.
*
* @param user
* @return
* @throws InternalErrorException
* @param user the user
* @return the info contact model
* @throws InternalErrorException the internal error exception
*/
public InfoContactModel buildGXTInfoContactModel(User user)
throws InternalErrorException {
@ -311,6 +352,14 @@ public class GWTWorkspaceSharingBuilder {
return new InfoContactModel();
}
/**
* Builds the gxt file model item.
*
* @param item the item
* @param parentFolderModel the parent folder model
* @return the file model
* @throws Exception the exception
*/
protected FileModel buildGXTFileModelItem(WorkspaceItem item,
FileModel parentFolderModel) throws Exception {
FileModel fileModel = null;
@ -366,6 +415,13 @@ public class GWTWorkspaceSharingBuilder {
}
/**
* Sets the folder item type.
*
* @param fileModel the file model
* @param worspaceFolderItem the worspace folder item
* @return the file model
*/
protected FileModel setFolderItemType(FileModel fileModel,
FolderItem worspaceFolderItem) {
@ -439,6 +495,13 @@ public class GWTWorkspaceSharingBuilder {
return fileModel;
}
/**
* Gets the workspace acl from ac ls.
*
* @param types the types
* @return the workspace acl from ac ls
* @throws Exception the exception
*/
public List<WorkspaceACL> getWorkspaceACLFromACLs(List<ACLType> types) throws Exception {
List<WorkspaceACL> acls = new ArrayList<WorkspaceACL>();
@ -483,8 +546,10 @@ public class GWTWorkspaceSharingBuilder {
}
/**
* @param aclOwner
* @return
* Gets the formatted html acl from ac ls.
*
* @param aclOwner the acl owner
* @return the formatted html acl from ac ls
*/
public String getFormattedHtmlACLFromACLs(Map<ACLType, List<String>> aclOwner) {

View File

@ -535,6 +535,12 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
InfoContactModel contact = builder.buildGxtInfoContactFromPortalLogin(credentialModel.getLogin());
contact.setReferenceCredential(credentialModel);
listContacts.add(contact);
logger.trace("Converted contact: "+credentialModel +", into: "+contact);
}else if(credentialModel.getName()==null || credentialModel.getName().isEmpty()){
InfoContactModel contact = builder.buildGxtInfoContactFromPortalGroup(credentialModel.getLogin());
contact.setReferenceCredential(credentialModel);
listContacts.add(contact);
logger.trace("Converted group: "+credentialModel +", into: "+contact);
}
}
@ -605,44 +611,6 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
return listContactsModel;
}
/**
* The main method.
*
* @param args the arguments
*/
public static void main(String[] args) {
WorkspaceSharingServiceImpl impl = new WorkspaceSharingServiceImpl();
PortalContext context = PortalContext.getConfiguration();
try {
String nameVO = "devsec";
String vrePath = ConstantsSharing.PATH_SEPARATOR+context.getInfrastructureName() + ConstantsSharing.PATH_SEPARATOR + nameVO + ConstantsSharing.PATH_SEPARATOR;
List<VO> lsVOs = WsUtil.getVresFromInfrastructure(context.getInfrastructureName(), nameVO);
GWTWorkspaceSharingBuilder builder = new GWTWorkspaceSharingBuilder();
List<InfoContactModel> groups = builder.buildGXTListContactsModelFromVOs(lsVOs, vrePath);
for (VO vo : lsVOs) {
System.out.println(vo.getName());
for (VRE vre : vo.getVres()) {
System.out.println("VRE: "+vre.getName());
}
}
for (InfoContactModel infoContactModel : groups) {
System.out.println(infoContactModel);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/* (non-Javadoc)
* @see org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingService#getACLForSharedItemId(java.lang.String)
*
@ -805,4 +773,81 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
return false;
}
}
/**
* Check list share name for group.
*
* @param listAlreadySharedContact the list already shared contact
* @return the list
*/
/*private static List<CredentialModel> checkShareNameForGroup(List<CredentialModel> listAlreadySharedContact){
if(listAlreadySharedContact==null)
return null;
for (CredentialModel credentialModel : listAlreadySharedContact) {
if(credentialModel.isGroup() && (credentialModel.getName()==null || credentialModel.getName().isEmpty())){
//RECOVERING VRE NAME
if(credentialModel.getLogin().contains("/")){
int start = credentialModel.getLogin().lastIndexOf("/");
int end = credentialModel.getLogin().length();
if(start<end){
credentialModel.setName(credentialModel.getLogin().substring(start+1, end));
}
}
}
}
return listAlreadySharedContact;
}*/
/**
* The main method.
*
* @param args the arguments
*/
public static void main(String[] args) {
/*try {
String root="gcube";
String nameVO = "devsec";
String vrePath = ConstantsSharing.PATH_SEPARATOR+root + ConstantsSharing.PATH_SEPARATOR + nameVO + ConstantsSharing.PATH_SEPARATOR;
List<VO> lsVOs = WsUtil.getVresFromInfrastructure(root, nameVO);
GWTWorkspaceSharingBuilder builder = new GWTWorkspaceSharingBuilder();
List<InfoContactModel> groups = builder.buildGXTListContactsModelFromVOs(lsVOs, vrePath);
for (VO vo : lsVOs) {
System.out.println(vo.getName());
for (VRE vre : vo.getVres()) {
System.out.println("VRE: "+vre.getName());
}
}
// for (InfoContactModel infoContactModel : groups) {
// System.out.println(infoContactModel);
// }
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}*/
/*List<CredentialModel> list = new ArrayList<CredentialModel>();
list.add(new CredentialModel(null, "test.user", false));
list.add(new CredentialModel(null, "/gcube/devsec/devVRE", true));
list.add(new CredentialModel(null, "francesco.mangiacrapa", false));
list.add(new CredentialModel(null, "devVRE", true));
list.add(new CredentialModel(null, "/gcube/devsec/NextNext", true));
list = checkListShareNameForGroup(list);
for (CredentialModel credentialModel : list) {
System.out.println(credentialModel);
}*/
}
}

View File

@ -17,8 +17,6 @@ import org.gcube.vomanagement.usermanagement.model.UserModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class UserUtil.
*
@ -47,7 +45,7 @@ public class UserUtil {
logger.info("Get user full name for: "+portalLogin);
logger.info("Into portal: "+WsUtil.isWithinPortal());
if ((portalLogin.compareTo(WsUtil.TEST_USER) != 0) && (WsUtil.isWithinPortal())) { //skip test.user
if (portalLogin.compareTo(WsUtil.TEST_USER) != 0 && WsUtil.isWithinPortal()) { //skip test.user
UserModel curr = null;
@ -69,15 +67,13 @@ public class UserUtil {
}
if (curr != null){
// logger.trace("Return "+curr.getFullname() +" full name for: "+portalLogin);
return curr.getFullname();
}
}else{
logger.info("Return "+WsUtil.TEST_USER_FULL_NAME +" full name for: "+portalLogin);
return WsUtil.TEST_USER_FULL_NAME;
logger.info("We are out of portal, returning login portalLogin "+portalLogin+ "as full name");
return portalLogin;
}
logger.info("Return portal login as full name for: "+portalLogin);

View File

@ -45,11 +45,8 @@ public class WsUtil {
public static final String NOTIFICATION_PRODUCER = "NOTIFICATION_SHARING_PRODUCER";
public static final String WORKSPACE_SCOPE_UTIL = "WORKSPACE_SHARING_SCOPE_UTIL";
public static final String NOTIFICATION_PORTLET_CLASS_ID = "org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl"; //USE THE SAME OF WORKSPACE
// public static final String TEST_SCOPE = "/gcube/devsec";
// public static final String TEST_USER = "pasquale.pagano";
public static final String TEST_SCOPE = "/gcube/devsec";
// public static final String TEST_USER = "federico.defaveri";
// public static final String TEST_USER = "massimiliano.assante";
@ -60,10 +57,7 @@ public class WsUtil {
public static final String TEST_USER = "test.user";
// public static final String TEST_USER = "antonio.gioia";
public static final String TEST_USER_FULL_NAME = "Test User";
protected static Logger logger = LoggerFactory.getLogger(WsUtil.class);
// public static boolean withoutPortal = false;
/**
@ -95,7 +89,6 @@ public class WsUtil {
//UNCOMMENT THIS IN DEVELOP ENVIROMENT
// user = "francesco.mangiacrapa";
logger.warn("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND - PORTLETS STARTING WITH FOLLOWING SETTINGS:");
logger.warn("session id: "+sessionID);
logger.warn("TEST_USER: "+user);
@ -103,30 +96,22 @@ public class WsUtil {
logger.warn("USERNAME_ATTRIBUTE: "+USERNAME_ATTRIBUTE);
session = SessionManager.getInstance().getASLSession(sessionID, user);
session.setScope(TEST_SCOPE);
//MANDATORY FOR SOCIAL LIBRARY
session.setUserAvatarId(user + "Avatar");
session.setUserFullName(TEST_USER_FULL_NAME);
session.setUserEmailAddress(user + "@mail.test");
//SET HTTP SESSION ATTRIBUTE
httpSession.setAttribute(USERNAME_ATTRIBUTE, user);
// withoutPortal = true;
return session;
}else if(user.compareToIgnoreCase(TEST_USER)==0){
// withoutPortal = true;
//COMMENT THIS IN PRODUCTION ENVIROMENT
// }else if(user.compareToIgnoreCase("francesco.mangiacrapa")==0){
//
// withoutPortal = false;
// END UNCOMMENT
}else{
// withoutPortal = false;
}

View File

@ -5,29 +5,38 @@ package org.gcube.portlets.widgets.workspacesharingwidget.shared;
import java.io.Serializable;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @Mar 3, 2014
* The Class CredentialModel.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Apr 14, 2016
*/
public class CredentialModel implements Serializable{
/**
*
*/
private static final long serialVersionUID = -4265499048265553603L;
private static final long serialVersionUID = 5312392409290548813L;
private String id;
private String login;
private boolean isGroup;
private String name;
/**
* Instantiates a new credential model.
*/
public CredentialModel(){
}
/**
* @param id
* @param login
* @param isGroup
* Instantiates a new credential model.
*
* @param id the id
* @param login the login
* @param isGroup the is group
*/
public CredentialModel(String id, String login, boolean isGroup) {
this.id = id;
@ -35,27 +44,98 @@ public class CredentialModel implements Serializable{
this.isGroup = isGroup;
}
/**
* Instantiates a new credential model.
*
* @param id the id
* @param login the login
* @param name the name
* @param isGroup the is group
*/
public CredentialModel(String id, String login, String name, boolean isGroup) {
this(id,login,isGroup);
this.name = name;
}
/**
* Gets the name.
*
* @return the name
*/
public String getName() {
return name;
}
/**
* Sets the name.
*
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* Gets the id.
*
* @return the id
*/
public String getId() {
return id;
}
/**
* Gets the login.
*
* @return the login
*/
public String getLogin() {
return login;
}
/**
* Checks if is group.
*
* @return true, if is group
*/
public boolean isGroup() {
return isGroup;
}
/**
* Sets the id.
*
* @param id the new id
*/
public void setId(String id) {
this.id = id;
}
/**
* Sets the login.
*
* @param login the new login
*/
public void setLogin(String login) {
this.login = login;
}
/**
* Sets the group.
*
* @param isGroup the new group
*/
public void setGroup(boolean isGroup) {
this.isGroup = isGroup;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("CredentialModel [id=");
builder.append(id);
@ -63,8 +143,9 @@ public class CredentialModel implements Serializable{
builder.append(login);
builder.append(", isGroup=");
builder.append(isGroup);
builder.append(", name=");
builder.append(name);
builder.append("]");
return builder.toString();
}
}