From 05c926a1d63a905615caa510e4284e48134c6c65 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Tue, 23 Jul 2019 10:02:03 +0000 Subject: [PATCH] ref 17169: Selection of users in the Sharing panel https://support.d4science.org/issues/17169 Added users discovery by keyword search git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@181294 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 6 +- .settings/org.eclipse.core.resources.prefs | 1 + .../model/ExtendedInfoContactModel.java | 4 +- .../view/sharing/DialogShareFolder.java | 10 +- .../client/view/sharing/MultiDragContact.java | 877 +++++----- .../workspace/server/GWTWorkspaceBuilder.java | 1542 +++++++++-------- .../StorageHubToWorkpaceConverter.java | 2 +- .../user/workspace/server/util/WsUtil.java | 14 +- 8 files changed, 1323 insertions(+), 1133 deletions(-) diff --git a/.classpath b/.classpath index 58453db..758273a 100644 --- a/.classpath +++ b/.classpath @@ -13,7 +13,11 @@ - + + + + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index f9fe345..839d647 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -1,4 +1,5 @@ eclipse.preferences.version=1 encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 encoding//src/test/java=UTF-8 encoding/=UTF-8 diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/model/ExtendedInfoContactModel.java b/src/main/java/org/gcube/portlets/user/workspace/client/model/ExtendedInfoContactModel.java index 8d608a0..411ce45 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/model/ExtendedInfoContactModel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/model/ExtendedInfoContactModel.java @@ -23,8 +23,8 @@ public class ExtendedInfoContactModel extends InfoContactModel { public ExtendedInfoContactModel() {} - public ExtendedInfoContactModel(String id, String login, String fullName, boolean isGroup) { - super(id, login, fullName, isGroup); + public ExtendedInfoContactModel(String id, String login, String fullName, String emailDomain,boolean isGroup) { + super(id, login, fullName, emailDomain, isGroup); } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/DialogShareFolder.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/DialogShareFolder.java index 9d6022e..3827165 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/DialogShareFolder.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/DialogShareFolder.java @@ -230,9 +230,9 @@ public class DialogShareFolder extends Dialog { for (InfoContactModel contact : listContacts) { if (contact != null && contact.getName() != null) { if (!isShareOwner(contact)) // skip owner - suggestPanel.addRecipient(contact.getName(), true); + suggestPanel.addRecipient(contact, true); else - suggestPanel.addRecipient(contact.getName(), false); // owner + suggestPanel.addRecipient(contact, false); // owner // is // not // deletable @@ -484,10 +484,10 @@ public class DialogShareFolder extends Dialog { suggestPanel.resetItemSelected(); // SHARE OWNER IS NULL IN CASE OF NEW SHARE if (shareOwner != null) - suggestPanel.addRecipient(shareOwner.getName(), false); + suggestPanel.addRecipient(shareOwner, false); for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) { - suggestPanel.addRecipient(infoContactModel.getName(), true); + suggestPanel.addRecipient(infoContactModel, true); } suggestPanel.boxSetFocus(); // printSelectedUser(); @@ -552,7 +552,7 @@ public class DialogShareFolder extends Dialog { private void initSuggestContacts() { suggestPanel.resetItemSelected(); for (InfoContactModel contact : listAlreadyShared) - suggestPanel.addRecipient(contact.getName(), false); + suggestPanel.addRecipient(contact, false); } /** diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/MultiDragContact.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/MultiDragContact.java index d50ffd7..1cf1648 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/MultiDragContact.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/MultiDragContact.java @@ -52,7 +52,7 @@ import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; * The Class MultiDragContact. * * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it - * Jun 1, 2016 + * Jun 1, 2016 */ public class MultiDragContact extends Dialog { @@ -66,10 +66,10 @@ public class MultiDragContact extends Dialog { private static final int HEIGHT_CONTAINER_TEXT_AREA = 72; private static final int HEIGHT_TEXT_AREA = 55; private static final int WIDTH_CP = 597; -// private static final int HEIGHT_DIALOG = 542; + // private static final int HEIGHT_DIALOG = 542; private static final int HEIGHT_DIALOG = 580; private static final int WIDTH_DIALOG = 630; -// private static final int WIDTH_DIALOG = 625; + // private static final int WIDTH_DIALOG = 625; private static final int HEIGHT_GRID = 310; private GridDropTarget dropSource; @@ -85,262 +85,260 @@ public class MultiDragContact extends Dialog { private Button buttonAllRight; private Button buttonAllLeft; - /** - * Instantiates a new multi drag contact. - */ - public MultiDragContact() { - setStyleAttribute("margin", "10px"); - setSize(WIDTH_DIALOG, HEIGHT_DIALOG); - setHeading("Group dragging contacts"); - setResizable(false); - setMaximizable(false); - setIcon(Resources.getIconUsers()); - setModal(true); - setScrollMode(Scroll.AUTOY); - setBodyStyle("padding: 9px; background: none"); - setResizable(true); - setButtonAlign(HorizontalAlignment.CENTER); - setButtons(Dialog.OKCANCEL); - //SORTING STORE - setGropUserStoreSorter(storeSource); - setGropUserStoreSorter(storeTarget); + /** + * Instantiates a new multi drag contact. + */ + public MultiDragContact() { + setStyleAttribute("margin", "10px"); + setSize(WIDTH_DIALOG, HEIGHT_DIALOG); + setHeading("Group dragging contacts"); + setResizable(false); + setMaximizable(false); + setIcon(Resources.getIconUsers()); + setModal(true); + setScrollMode(Scroll.AUTOY); + setBodyStyle("padding: 9px; background: none"); + setResizable(true); + setButtonAlign(HorizontalAlignment.CENTER); + setButtons(Dialog.OKCANCEL); + // SORTING STORE + setGropUserStoreSorter(storeSource); + setGropUserStoreSorter(storeTarget); - ContentPanel cpAlreadyShared = new ContentPanel(); - cpAlreadyShared.setSize(WIDTH_CP, HEIGHT_CONTAINER_TEXT_AREA); - cpAlreadyShared.setHeaderVisible(false); - cpAlreadyShared.setLayout(new FitLayout()); + ContentPanel cpAlreadyShared = new ContentPanel(); + cpAlreadyShared.setSize(WIDTH_CP, HEIGHT_CONTAINER_TEXT_AREA); + cpAlreadyShared.setHeaderVisible(false); + cpAlreadyShared.setLayout(new FitLayout()); - VerticalPanel vpShared = new VerticalPanel(); - vpShared.setVerticalAlign(VerticalAlignment.MIDDLE); - vpShared.setHorizontalAlign(HorizontalAlignment.CENTER); - vpShared.setStyleAttribute("padding", "5px"); - vpShared.setLayout(new FitLayout()); - HorizontalPanel hpSharedContacts = new HorizontalPanel(); - hpSharedContacts.setHorizontalAlign(HorizontalAlignment.CENTER); - hpSharedContacts.setVerticalAlign(VerticalAlignment.MIDDLE); - textAreaAlreadyShared = new TextArea(); -// textField.setFieldLabel("Already shared with"); -// textField.setHeight(30); - textAreaAlreadyShared.setWidth(501); - textAreaAlreadyShared.setHeight(HEIGHT_TEXT_AREA); - cpAlreadyShared.setStyleAttribute("padding-bottom", "5px"); - textAreaAlreadyShared.setReadOnly(true); - cpAlreadyShared.add(textAreaAlreadyShared); + VerticalPanel vpShared = new VerticalPanel(); + vpShared.setVerticalAlign(VerticalAlignment.MIDDLE); + vpShared.setHorizontalAlign(HorizontalAlignment.CENTER); + vpShared.setStyleAttribute("padding", "5px"); + vpShared.setLayout(new FitLayout()); + HorizontalPanel hpSharedContacts = new HorizontalPanel(); + hpSharedContacts.setHorizontalAlign(HorizontalAlignment.CENTER); + hpSharedContacts.setVerticalAlign(VerticalAlignment.MIDDLE); + textAreaAlreadyShared = new TextArea(); + // textField.setFieldLabel("Already shared with"); + // textField.setHeight(30); + textAreaAlreadyShared.setWidth(501); + textAreaAlreadyShared.setHeight(HEIGHT_TEXT_AREA); + cpAlreadyShared.setStyleAttribute("padding-bottom", "5px"); + textAreaAlreadyShared.setReadOnly(true); + cpAlreadyShared.add(textAreaAlreadyShared); - Label label = new Label("Already shared with"); - label.setStyleAttribute("padding-right", "10px"); - label.setStyleAttribute("font-size", "12px"); + Label label = new Label("Already shared with"); + label.setStyleAttribute("padding-right", "10px"); + label.setStyleAttribute("font-size", "12px"); - hpSharedContacts.add(label); - hpSharedContacts.add(textAreaAlreadyShared); - vpShared.add(hpSharedContacts); - cpAlreadyShared.add(vpShared); - add(cpAlreadyShared); + hpSharedContacts.add(label); + hpSharedContacts.add(textAreaAlreadyShared); + vpShared.add(hpSharedContacts); + cpAlreadyShared.add(vpShared); + add(cpAlreadyShared); + final ContentPanel cp = new ContentPanel(); + cp.setSize(WIDTH_CP, HEIGHT_CONTAINER_GRID); + cp.setHeaderVisible(false); + cp.setLayout(new RowLayout(Orientation.HORIZONTAL)); - final ContentPanel cp = new ContentPanel(); - cp.setSize(WIDTH_CP, HEIGHT_CONTAINER_GRID); - cp.setHeaderVisible(false); - cp.setLayout(new RowLayout(Orientation.HORIZONTAL)); + ToolBar toolBar = new ToolBar(); + Button buttonHelp = new Button(); + buttonHelp.setIcon(Resources.getIconInfo()); - ToolBar toolBar = new ToolBar(); - Button buttonHelp = new Button(); - buttonHelp.setIcon(Resources.getIconInfo()); + buttonHelp.addSelectionListener(new SelectionListener() { - buttonHelp.addSelectionListener(new SelectionListener() { + @Override + public void componentSelected(ButtonEvent ce) { + MessageBox.info("Group dragging action", + "Drag one or more contacts from the left (All Contacts) to the right (Share with) to add users in your sharing list.", + null); - @Override - public void componentSelected(ButtonEvent ce) { - MessageBox.info("Group dragging action", "Drag one or more contacts from the left (All Contacts) to the right (Share with) to add users in your sharing list.", null); - - } - }); - - toolBar.add(buttonHelp); - setTopComponent(toolBar); - - final VerticalPanel vpAllContacts = new VerticalPanel(); - vpAllContacts.setHorizontalAlign(HorizontalAlignment.CENTER); - vpAllContacts.add(new Label("All Contacts")); - - gridAllContacts = new Grid(storeSource, createColumnModel()); - - - GridCellRenderer displayNameCellRender = new GridCellRenderer() { - public String render(ExtendedInfoContactModel model, String property, ColumnData config, int rowIndex, int colIndex, ListStore store, Grid grid) { - - if(model!=null){ - - String value = model.get (property); - if (value != null){ - return "" + value + ""; - } - } - - return ""; - } - }; - - columnConfigDisplayName.setRenderer(displayNameCellRender); - - storeSource.setDefaultSort(InfoContactModel.FULLNAME, SortDir.ASC); - storeSource.sort(InfoContactModel.FULLNAME, SortDir.ASC); - - storeTarget.setDefaultSort(InfoContactModel.FULLNAME, SortDir.ASC); - storeTarget.sort(InfoContactModel.FULLNAME, SortDir.ASC); - - - final StoreFilterField filter = new StoreFilterField() { - - @Override - protected boolean doSelect(Store store, - ExtendedInfoContactModel parent, ExtendedInfoContactModel record, - String property, String filter) { - - String name = record.getName(); - name = name.toLowerCase(); - if (name.contains(filter.toLowerCase())) { - return true; } - return false; - } + }); - }; + toolBar.add(buttonHelp); + setTopComponent(toolBar); - filter.setEmptyText("Filter All Contacts"); - HorizontalPanel hp = new HorizontalPanel(); - hp.setStyleAttribute("padding-top", "5px"); - hp.setStyleAttribute("padding-bottom", "5px"); - hp.add(filter); - filter.bind(storeSource); + final VerticalPanel vpAllContacts = new VerticalPanel(); + vpAllContacts.setHorizontalAlign(HorizontalAlignment.CENTER); + vpAllContacts.add(new Label("All Contacts")); - gridAllContacts.setHeight(HEIGHT_GRID); - gridAllContacts.setBorders(false); - gridAllContacts.getView().setAutoFill(true); - gridAllContacts.setBorders(true); + gridAllContacts = new Grid(storeSource, createColumnModel()); - vpAllContacts.add(hp); - vpAllContacts.add(gridAllContacts); + GridCellRenderer displayNameCellRender = new GridCellRenderer() { + public String render(ExtendedInfoContactModel model, String property, ColumnData config, int rowIndex, + int colIndex, ListStore store, Grid grid) { - RowData rowData = new RowData(.4, 1); - rowData.setMargins(new Margins(6)); - cp.add(vpAllContacts, rowData); + if (model != null) { - rowData = new RowData(.2, 1); - rowData.setMargins(new Margins(6)); - LayoutContainer lc = createMoveContactsContainer(); - cp.add(lc, rowData); - - rowData = new RowData(.4, 1); - rowData.setMargins(new Margins(6, 6, 6, 0)); - - final VerticalPanel vpShareWith = new VerticalPanel(); - vpShareWith.setHorizontalAlign(HorizontalAlignment.CENTER); - vpShareWith.add(new Label("Share with...")); - gridShareWith = new Grid(storeTarget, createColumnModel()); - - final StoreFilterField filter2 = new StoreFilterField() { - - @Override - protected boolean doSelect(Store store, - ExtendedInfoContactModel parent, ExtendedInfoContactModel record, - String property, String filter) { - - String name = record.getName(); - name = name.toLowerCase(); - if (name.contains(filter.toLowerCase())) { - return true; - } - return false; - } - - }; - - filter2.setEmptyText("Filter Share with"); - - hp = new HorizontalPanel(); - hp.setStyleAttribute("padding-top", "5px"); - hp.setStyleAttribute("padding-bottom", "5px"); - hp.add(filter2); - filter2.bind(storeTarget); - - gridShareWith.setHeight(HEIGHT_GRID); - gridShareWith.setBorders(false); - gridShareWith.getView().setAutoFill(true); -// gridShareWith.setAutoExpandColumn(InfoContactModel.FULLNAME); - gridShareWith.setBorders(true); - vpShareWith.add(hp); - vpShareWith.add(gridShareWith); - - cp.add(vpShareWith, rowData); - - new GridDragSource(gridAllContacts); - new GridDragSource(gridShareWith); - - dropSource = new GridDropTarget(gridAllContacts); - dropSource.setAllowSelfAsSource(false); - - dropTarget = new GridDropTarget(gridShareWith); - dropTarget.setAllowSelfAsSource(false); - - add(cp); - - this.getButtonById(Dialog.CANCEL).addSelectionListener(new SelectionListener() { - - @Override - public void componentSelected(ButtonEvent ce) { - hide(); - } - }); - - - this.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener() { - - @Override - public void componentSelected(ButtonEvent ce) { - List shareContacts = storeTarget.getModels(); - - if(shareContacts==null || shareContacts.isEmpty()){ - - MessageBoxConfirm mbc = new MessageBoxConfirm("Confirm exit?", "You have not selected any contact to share, confirm exit?"); - - mbc.getMessageBoxConfirm().addCallback(new Listener() { - - @Override - public void handleEvent(MessageBoxEvent be) { - String clickedButton = be.getButtonClicked().getItemId(); - if(clickedButton.equals(Dialog.YES)){ - hide(); - } + String value = model.get(property); + if (value != null) { + return "" + value + ""; } - }); - }else + } + + return ""; + } + }; + + columnConfigDisplayName.setRenderer(displayNameCellRender); + + storeSource.setDefaultSort(InfoContactModel.FULLNAME, SortDir.ASC); + storeSource.sort(InfoContactModel.FULLNAME, SortDir.ASC); + + storeTarget.setDefaultSort(InfoContactModel.FULLNAME, SortDir.ASC); + storeTarget.sort(InfoContactModel.FULLNAME, SortDir.ASC); + + final StoreFilterField filter = new StoreFilterField() { + + @Override + protected boolean doSelect(Store store, ExtendedInfoContactModel parent, + ExtendedInfoContactModel record, String property, String filter) { + + String name = record.getName(); + name = name.toLowerCase(); + if (name.contains(filter.toLowerCase())) { + return true; + } + return false; + } + + }; + + filter.setEmptyText("Filter All Contacts"); + HorizontalPanel hp = new HorizontalPanel(); + hp.setStyleAttribute("padding-top", "5px"); + hp.setStyleAttribute("padding-bottom", "5px"); + hp.add(filter); + filter.bind(storeSource); + + gridAllContacts.setHeight(HEIGHT_GRID); + gridAllContacts.setBorders(false); + gridAllContacts.getView().setAutoFill(true); + gridAllContacts.setBorders(true); + + vpAllContacts.add(hp); + vpAllContacts.add(gridAllContacts); + + RowData rowData = new RowData(.4, 1); + rowData.setMargins(new Margins(6)); + cp.add(vpAllContacts, rowData); + + rowData = new RowData(.2, 1); + rowData.setMargins(new Margins(6)); + LayoutContainer lc = createMoveContactsContainer(); + cp.add(lc, rowData); + + rowData = new RowData(.4, 1); + rowData.setMargins(new Margins(6, 6, 6, 0)); + + final VerticalPanel vpShareWith = new VerticalPanel(); + vpShareWith.setHorizontalAlign(HorizontalAlignment.CENTER); + vpShareWith.add(new Label("Share with...")); + gridShareWith = new Grid(storeTarget, createColumnModel()); + + final StoreFilterField filter2 = new StoreFilterField() { + + @Override + protected boolean doSelect(Store store, ExtendedInfoContactModel parent, + ExtendedInfoContactModel record, String property, String filter) { + + String name = record.getName(); + name = name.toLowerCase(); + if (name.contains(filter.toLowerCase())) { + return true; + } + return false; + } + + }; + + filter2.setEmptyText("Filter Share with"); + + hp = new HorizontalPanel(); + hp.setStyleAttribute("padding-top", "5px"); + hp.setStyleAttribute("padding-bottom", "5px"); + hp.add(filter2); + filter2.bind(storeTarget); + + gridShareWith.setHeight(HEIGHT_GRID); + gridShareWith.setBorders(false); + gridShareWith.getView().setAutoFill(true); + // gridShareWith.setAutoExpandColumn(InfoContactModel.FULLNAME); + gridShareWith.setBorders(true); + vpShareWith.add(hp); + vpShareWith.add(gridShareWith); + + cp.add(vpShareWith, rowData); + + new GridDragSource(gridAllContacts); + new GridDragSource(gridShareWith); + + dropSource = new GridDropTarget(gridAllContacts); + dropSource.setAllowSelfAsSource(false); + + dropTarget = new GridDropTarget(gridShareWith); + dropTarget.setAllowSelfAsSource(false); + + add(cp); + + this.getButtonById(Dialog.CANCEL).addSelectionListener(new SelectionListener() { + + @Override + public void componentSelected(ButtonEvent ce) { hide(); - } - }); + } + }); - // needed to enable quicktips (qtitle for the heading and qtip for the - // content) that are setup in the change GridCellRenderer + this.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener() { - cp.addListener(Events.Render, new Listener() { + @Override + public void componentSelected(ButtonEvent ce) { + List shareContacts = storeTarget.getModels(); - @Override - public void handleEvent(BaseEvent be) { - int width = gridAllContacts.getWidth(); - filter.setWidth(width-2); - filter2.setWidth(width-2); - gridShareWith.setWidth(width+5); - vpShareWith.setWidth(width+15); - gridAllContacts.setWidth(width+5); - vpAllContacts.setWidth(width+15); - vpShareWith.layout(); - vpAllContacts.layout(); - cp.layout(); - } - }); + if (shareContacts == null || shareContacts.isEmpty()) { - new QuickTip(gridAllContacts); - } + MessageBoxConfirm mbc = new MessageBoxConfirm("Confirm exit?", + "You have not selected any contact to share, confirm exit?"); + + mbc.getMessageBoxConfirm().addCallback(new Listener() { + + @Override + public void handleEvent(MessageBoxEvent be) { + String clickedButton = be.getButtonClicked().getItemId(); + if (clickedButton.equals(Dialog.YES)) { + hide(); + } + } + }); + } else + hide(); + } + }); + + // needed to enable quicktips (qtitle for the heading and qtip for the + // content) that are setup in the change GridCellRenderer + + cp.addListener(Events.Render, new Listener() { + + @Override + public void handleEvent(BaseEvent be) { + int width = gridAllContacts.getWidth(); + filter.setWidth(width - 2); + filter2.setWidth(width - 2); + gridShareWith.setWidth(width + 5); + vpShareWith.setWidth(width + 15); + gridAllContacts.setWidth(width + 5); + vpAllContacts.setWidth(width + 15); + vpShareWith.layout(); + vpAllContacts.layout(); + cp.layout(); + } + }); + + new QuickTip(gridAllContacts); + } /** * Creates the move contacts container. @@ -357,94 +355,82 @@ public class MultiDragContact extends Dialog { buttonSelectedLeft = new Button(); buttonSelectedLeft.setIcon(Resources.getSelectedLeft()); - buttonSelectedLeft - .setToolTip("Move selected contact/s from 'All Contact' to 'Share with'"); - buttonSelectedLeft - .addSelectionListener(new SelectionListener() { + buttonSelectedLeft.setToolTip("Move selected contact/s from 'All Contact' to 'Share with'"); + buttonSelectedLeft.addSelectionListener(new SelectionListener() { - @Override - public void componentSelected(ButtonEvent ce) { + @Override + public void componentSelected(ButtonEvent ce) { - List selectedItems = gridAllContacts - .getSelectionModel().getSelectedItems(); + List selectedItems = gridAllContacts.getSelectionModel().getSelectedItems(); - if (selectedItems != null && selectedItems.size() > 0) { + if (selectedItems != null && selectedItems.size() > 0) { - for (ExtendedInfoContactModel extendedInfoContactModel : selectedItems) { - storeTarget.add(extendedInfoContactModel); - storeSource.remove(extendedInfoContactModel); - } - } + for (ExtendedInfoContactModel extendedInfoContactModel : selectedItems) { + storeTarget.add(extendedInfoContactModel); + storeSource.remove(extendedInfoContactModel); } - }); + } + } + }); buttonSelectedRight = new Button(); buttonSelectedRight.setIcon(Resources.getSelectedRight()); - buttonSelectedRight - .setToolTip("Move selected contact/s from 'Share with' to 'All Contact'"); + buttonSelectedRight.setToolTip("Move selected contact/s from 'Share with' to 'All Contact'"); - buttonSelectedRight - .addSelectionListener(new SelectionListener() { + buttonSelectedRight.addSelectionListener(new SelectionListener() { - @Override - public void componentSelected(ButtonEvent ce) { + @Override + public void componentSelected(ButtonEvent ce) { - List selectedItems = gridShareWith - .getSelectionModel().getSelectedItems(); + List selectedItems = gridShareWith.getSelectionModel().getSelectedItems(); - if (selectedItems != null && selectedItems.size() > 0) { + if (selectedItems != null && selectedItems.size() > 0) { - for (ExtendedInfoContactModel extendedInfoContactModel : selectedItems) { - storeSource.add(extendedInfoContactModel); - storeTarget.remove(extendedInfoContactModel); - } - } + for (ExtendedInfoContactModel extendedInfoContactModel : selectedItems) { + storeSource.add(extendedInfoContactModel); + storeTarget.remove(extendedInfoContactModel); } - }); + } + } + }); buttonAllLeft = new Button(); buttonAllLeft.setIcon(Resources.getAllLeft()); - buttonAllLeft - .setToolTip("Move all contact/s from 'All Contact' to 'Share with'"); + buttonAllLeft.setToolTip("Move all contact/s from 'All Contact' to 'Share with'"); - buttonAllLeft - .addSelectionListener(new SelectionListener() { + buttonAllLeft.addSelectionListener(new SelectionListener() { - @Override - public void componentSelected(ButtonEvent ce) { - - if (storeSource != null && storeSource.getCount() > 0) { - for (ExtendedInfoContactModel extendedInfoContactModel : storeSource - .getModels()) { - storeTarget.add(extendedInfoContactModel); - storeSource.remove(extendedInfoContactModel); - } - } + @Override + public void componentSelected(ButtonEvent ce) { + if (storeSource != null && storeSource.getCount() > 0) { + for (ExtendedInfoContactModel extendedInfoContactModel : storeSource.getModels()) { + storeTarget.add(extendedInfoContactModel); + storeSource.remove(extendedInfoContactModel); } - }); + } + + } + }); buttonAllRight = new Button(); buttonAllRight.setIcon(Resources.getAllRight()); - buttonAllRight - .setToolTip("Move all contact/s from 'Share with' to 'All Contact'"); + buttonAllRight.setToolTip("Move all contact/s from 'Share with' to 'All Contact'"); - buttonAllRight - .addSelectionListener(new SelectionListener() { + buttonAllRight.addSelectionListener(new SelectionListener() { - @Override - public void componentSelected(ButtonEvent ce) { - - if (storeTarget != null && storeTarget.getCount() > 0) { - for (ExtendedInfoContactModel extendedInfoContactModel : storeTarget - .getModels()) { - storeSource.add(extendedInfoContactModel); - storeTarget.remove(extendedInfoContactModel); - } - } + @Override + public void componentSelected(ButtonEvent ce) { + if (storeTarget != null && storeTarget.getCount() > 0) { + for (ExtendedInfoContactModel extendedInfoContactModel : storeTarget.getModels()) { + storeSource.add(extendedInfoContactModel); + storeTarget.remove(extendedInfoContactModel); } - }); + } + + } + }); vp1.add(buttonSelectedLeft); vp1.add(buttonAllLeft); @@ -468,175 +454,186 @@ public class MultiDragContact extends Dialog { return lc; } - /** - * Creates the column model. - * - * @return the column model - */ - private ColumnModel createColumnModel() { - List configs = new ArrayList(); + /** + * Creates the column model. + * + * @return the column model + */ + private ColumnModel createColumnModel() { + List configs = new ArrayList(); - ColumnConfig icon = new ColumnConfig(ExtendedInfoContactModel.ICON, "", 25); - configs.add(icon); + ColumnConfig icon = new ColumnConfig(ExtendedInfoContactModel.ICON, "", 25); + configs.add(icon); - columnConfigDisplayName = new ColumnConfig(ExtendedInfoContactModel.FULLNAME, "Name", 150); - configs.add(columnConfigDisplayName); + columnConfigDisplayName = new ColumnConfig(ExtendedInfoContactModel.FULLNAME, "Name", 150); + configs.add(columnConfigDisplayName); - ColumnConfig type = new ColumnConfig(ExtendedInfoContactModel.ISGROUP, "Type", 50); - configs.add(type); + ColumnConfig type = new ColumnConfig(ExtendedInfoContactModel.ISGROUP, "Type", 50); + configs.add(type); + GridCellRenderer typeRender = new GridCellRenderer() { + @Override + public String render(ExtendedInfoContactModel model, String property, ColumnData config, int rowIndex, + int colIndex, ListStore store, Grid grid) { + Boolean isGroup = (Boolean) model.get(property); + String color = "#0F4FA8"; + String val = ""; + if (isGroup) { + val = "Group"; + color = "#05316D"; + return "" + val + ""; + } else { + val = "User"; + return "" + val + ""; + } + } + }; - GridCellRenderer typeRender = new GridCellRenderer() { - @Override - public String render(ExtendedInfoContactModel model, String property, ColumnData config, int rowIndex, int colIndex, ListStore store, Grid grid) { - Boolean isGroup = (Boolean) model.get(property); - String color = "#0F4FA8"; - String val = ""; - if(isGroup){ - val = "Group"; - color = "#05316D"; - return "" + val + ""; - }else{ - val = "User"; - return "" + val + ""; - } + type.setRenderer(typeRender); + return new ColumnModel(configs); + } + + /** + * Adds the source contacts. + * + * @param listContact + * the list contact + */ + public void addSourceContacts(List listContact) { + + gridAllContacts.mask("", ConstantsExplorer.LOADINGSTYLE); + if (listContact != null && listContact.size() > 0) { + List listExtended = new ArrayList(); + // SETTING ICONS + for (InfoContactModel infoContactModel : listContact) { + ExtendedInfoContactModel ext = new ExtendedInfoContactModel(infoContactModel.getId(), + infoContactModel.getLogin(), infoContactModel.getName(), infoContactModel.getEmailDomain(), + infoContactModel.isGroup()); + ext.setIcon(); + listExtended.add(ext); + } + + storeSource.add(listExtended); + // GWT.log("Added sources: "+listExtended.toString()); } - }; - type.setRenderer(typeRender); - return new ColumnModel(configs); - } + gridAllContacts.unmask(); + gridAllContacts.repaint(); + } - /** - * Adds the source contacts. - * - * @param listContact the list contact - */ - public void addSourceContacts(List listContact){ + /** + * Adds the already shared contacts. + * + * @param listContact + * the list contact + */ + public void addAlreadySharedContacts(List listContact) { - gridAllContacts.mask("", ConstantsExplorer.LOADINGSTYLE); - if(listContact!=null && listContact.size()>0){ - List listExtended = new ArrayList(); - //SETTING ICONS - for (InfoContactModel infoContactModel : listContact) { - ExtendedInfoContactModel ext = new ExtendedInfoContactModel(infoContactModel.getId(), infoContactModel.getLogin(), infoContactModel.getName(), infoContactModel.isGroup()); - ext.setIcon(); - listExtended.add(ext); - } + gridShareWith.mask("", ConstantsExplorer.LOADINGSTYLE); + if (listContact != null && listContact.size() > 0) { - storeSource.add(listExtended); -// GWT.log("Added sources: "+listExtended.toString()); - } + String alreadyShared = ""; + for (int i = 0; i < listContact.size() - 1; i++) + alreadyShared += listContact.get(i).getName() + ", "; - gridAllContacts.unmask(); - gridAllContacts.repaint(); - } + alreadyShared += listContact.get(listContact.size() - 1).getName(); - /** - * Adds the already shared contacts. - * - * @param listContact the list contact - */ - public void addAlreadySharedContacts(List listContact){ + textAreaAlreadyShared.setValue(alreadyShared); + } + gridShareWith.unmask(); - gridShareWith.mask("", ConstantsExplorer.LOADINGSTYLE); - if(listContact!=null && listContact.size()>0){ + } - String alreadyShared = ""; - for (int i=0; i listContact) { + if (listContact != null && listContact.size() > 0) { + storeTarget.add(convertFromInfoContactModel(listContact)); + } + } - alreadyShared+=listContact.get(listContact.size()-1).getName(); + /** + * Convert from info contact model. + * + * @param listContact + * the list contact + * @return the list + */ + private List convertFromInfoContactModel(List listContact) { - textAreaAlreadyShared.setValue(alreadyShared); - } - gridShareWith.unmask(); + if (listContact != null) { + List listExtended = new ArrayList(listContact.size()); + // SETTING ICONS + for (InfoContactModel infoContactModel : listContact) { + listExtended.add(convertFromInfoContactModel(infoContactModel)); + } + return listExtended; + } + return new ArrayList(); + } - } + /** + * Convert from info contact model. + * + * @param infoContactModel + * the info contact model + * @return the extended info contact model + */ + private ExtendedInfoContactModel convertFromInfoContactModel(InfoContactModel infoContactModel) { + if (infoContactModel != null) { + String fullName = infoContactModel.getName(); + if (fullName == null || fullName.isEmpty()) + fullName = infoContactModel.getLogin(); - /** - * Adds the target contacts. - * - * @param listContact the list contact - */ - public void addTargetContacts(List listContact){ - if(listContact!=null && listContact.size()>0){ - storeTarget.add(convertFromInfoContactModel(listContact)); - } - } + ExtendedInfoContactModel ext = new ExtendedInfoContactModel(infoContactModel.getId(), + infoContactModel.getLogin(), fullName, infoContactModel.getEmailDomain(), + infoContactModel.isGroup()); + ext.setIcon(); + return ext; + } + return new ExtendedInfoContactModel(); + } - /** - * Convert from info contact model. - * - * @param listContact the list contact - * @return the list - */ - private List convertFromInfoContactModel(List listContact){ + /** + * Adds the target contact. + * + * @param contact + * the contact + */ + public void addTargetContact(InfoContactModel contact) { + if (contact != null) + storeTarget.add(convertFromInfoContactModel(contact)); + } - if(listContact!=null){ - List listExtended = new ArrayList(listContact.size()); - //SETTING ICONS - for (InfoContactModel infoContactModel : listContact) { - listExtended.add(convertFromInfoContactModel(infoContactModel)); - } - return listExtended; - } - return new ArrayList(); - } + /** + * Gets the target list contact. + * + * @return the target list contact + */ + public List getTargetListContact() { - /** - * Convert from info contact model. - * - * @param infoContactModel the info contact model - * @return the extended info contact model - */ - private ExtendedInfoContactModel convertFromInfoContactModel(InfoContactModel infoContactModel){ - if(infoContactModel!=null){ - String fullName = infoContactModel.getName(); - if(fullName==null || fullName.isEmpty()) - fullName = infoContactModel.getLogin(); + List infoContacts = storeTarget.getModels(); + return (List) infoContacts; + } - ExtendedInfoContactModel ext = new ExtendedInfoContactModel(infoContactModel.getId(), infoContactModel.getLogin(), fullName, infoContactModel.isGroup()); - ext.setIcon(); - return ext; - } - return new ExtendedInfoContactModel(); - } - - /** - * Adds the target contact. - * - * @param contact the contact - */ - public void addTargetContact(InfoContactModel contact){ - if(contact!=null) - storeTarget.add(convertFromInfoContactModel(contact)); - } - - /** - * Gets the target list contact. - * - * @return the target list contact - */ - public List getTargetListContact(){ - - List infoContacts = storeTarget.getModels(); - return (List) infoContacts; - } - - - /** - * Sets the grop user store sorter. - * - * @param store the new grop user store sorter - */ - private void setGropUserStoreSorter(ListStore store){ + /** + * Sets the grop user store sorter. + * + * @param store + * the new grop user store sorter + */ + private void setGropUserStoreSorter(ListStore store) { // Sorting files - store.setStoreSorter(new StoreSorter() { + store.setStoreSorter(new StoreSorter() { @Override - public int compare(Store store, ExtendedInfoContactModel m1, ExtendedInfoContactModel m2, String property) { + public int compare(Store store, ExtendedInfoContactModel m1, + ExtendedInfoContactModel m2, String property) { boolean m1Folder = m1.isGroup(); boolean m2Folder = m2.isGroup(); diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java index 4411487..1cc3a7e 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java @@ -88,13 +88,12 @@ import org.gcube.vomanagement.usermanagement.model.GCubeUser; import com.thoughtworks.xstream.XStream; - // TODO: Auto-generated Javadoc /** * The Class GWTWorkspaceBuilder. * * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it - * Nov 30, 2016 + * Nov 30, 2016 */ public class GWTWorkspaceBuilder { @@ -110,51 +109,75 @@ public class GWTWorkspaceBuilder { public GWTWorkspaceBuilder() { } - /** * Used in test mode. * * @return the hash test users */ - public static HashMap getHashTestUsers(){ + public static HashMap getHashTestUsers() { - if(hashTestUser==null){ + if (hashTestUser == null) { hashTestUser = new HashMap(); - //USERS - hashTestUser.put("federico.defaveri", new InfoContactModel("federico.defaveri", "federico.defaveri", "Federico de Faveri",false)); - hashTestUser.put("antonio.gioia", new InfoContactModel("antonio.gioia", "antonio.gioia", "Antonio Gioia",false)); - hashTestUser.put("fabio.sinibaldi", new InfoContactModel("fabio.sinibaldi", "fabio.sinibaldi", "Fabio Sinibaldi",false)); - hashTestUser.put("pasquale.pagano", new InfoContactModel("pasquale.pagano", "pasquale.pagano", "Pasquale Pagano",false)); - hashTestUser.put("valentina.marioli", new InfoContactModel("valentina.marioli", "valentina.marioli", "Valentina Marioli",false)); - hashTestUser.put("roberto.cirillo", new InfoContactModel("roberto.cirillo", "roberto.cirillo", "Roberto Cirillo",false)); - hashTestUser.put("francesco.mangiacrapa", new InfoContactModel("francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa",false)); - hashTestUser.put("massimiliano.assante", new InfoContactModel("massimiliano.assante", "massimiliano.assante", "Massimiliano Assante",false)); + // USERS + hashTestUser.put("federico.defaveri", new InfoContactModel("federico.defaveri", "federico.defaveri", + "Federico de Faveri", "@isti.cnr.it", false)); + hashTestUser.put("antonio.gioia", + new InfoContactModel("antonio.gioia", "antonio.gioia", "Antonio Gioia", "@isti.cnr.it", false)); + hashTestUser.put("fabio.sinibaldi", new InfoContactModel("fabio.sinibaldi", "fabio.sinibaldi", + "Fabio Sinibaldi", "@isti.cnr.it", false)); + hashTestUser.put("pasquale.pagano", new InfoContactModel("pasquale.pagano", "pasquale.pagano", + "Pasquale Pagano", "@isti.cnr.it", false)); + hashTestUser.put("valentina.marioli", new InfoContactModel("valentina.marioli", "valentina.marioli", + "Valentina Marioli", "@isti.cnr.it", false)); + hashTestUser.put("roberto.cirillo", new InfoContactModel("roberto.cirillo", "roberto.cirillo", + "Roberto Cirillo", "@isti.cnr.it", false)); + hashTestUser.put("francesco.mangiacrapa", new InfoContactModel("francesco.mangiacrapa", + "francesco.mangiacrapa", "Francesco Mangiacrapa", "@isti.cnr.it", false)); + hashTestUser.put("massimiliano.assante", new InfoContactModel("massimiliano.assante", + "massimiliano.assante", "Massimiliano Assante", "@isti.cnr.it", false)); - // try{ - // logger.info("Sleeping for testing..."); - // Thread.sleep(30000); - // logger.info("Alive again"); - // }catch(Exception e){ + // try{ + // logger.info("Sleeping for testing..."); + // Thread.sleep(30000); + // logger.info("Alive again"); + // }catch(Exception e){ // - // } - //GROUPS - // hashTestUser.put("/gcube/devsec/devVRE", new InfoContactModel("/gcube/devsec/devVRE", "/gcube/devsec/devVRE", "",true)); - // hashTestUser.put("/gcube/devsec/gcube-test-test", new InfoContactModel("/gcube/devsec/gcube-test-test", "/gcube/gcube-test-test", "",true)); + // } + // GROUPS + // hashTestUser.put("/gcube/devsec/devVRE", new + // InfoContactModel("/gcube/devsec/devVRE", "/gcube/devsec/devVRE", + // "",true)); + // hashTestUser.put("/gcube/devsec/gcube-test-test", new + // InfoContactModel("/gcube/devsec/gcube-test-test", + // "/gcube/gcube-test-test", "",true)); } return hashTestUser; } + /** + * 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"; + } /** * To date. * - * @param calendar the calendar + * @param calendar + * the calendar * @return the date */ - public static Date toDate(Calendar calendar){ - if (calendar == null) return new Date(0); + public static Date toDate(Calendar calendar) { + if (calendar == null) + return new Date(0); return calendar.getTime(); } @@ -162,10 +185,11 @@ public class GWTWorkspaceBuilder { /** * To date format to string. * - * @param calendar the calendar + * @param calendar + * the calendar * @return the string */ - protected String toDateFormatToString(Calendar calendar){ + protected String toDateFormatToString(Calendar calendar) { SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM, yyyy HH:mm:ss z"); Date resultdate = getDate(calendar); @@ -181,24 +205,22 @@ public class GWTWorkspaceBuilder { */ protected Date toDateFormat(Calendar calendar) { - SimpleDateFormat dateFormat = - new SimpleDateFormat("dd-MM, yyyy HH:mm:ss z"); + SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM, yyyy HH:mm:ss z"); Date resultdate = getDate(calendar); try { resultdate = dateFormat.parse(dateFormat.format(resultdate)); - } - catch (ParseException e) { + } catch (ParseException e) { e.printStackTrace(); resultdate = new Date(0); } return resultdate; } - /** * Gets the date. * - * @param calendar the calendar + * @param calendar + * the calendar * @return the date */ private Date getDate(Calendar calendar) { @@ -217,67 +239,74 @@ public class GWTWorkspaceBuilder { /** * Builds the gwt properties. * - * @param metadata the metadata + * @param metadata + * the metadata * @return the GWT properties - * @throws InternalErrorException the internal error exception + * @throws InternalErrorException + * the internal error exception */ - protected GWTProperties buildGWTProperties(Properties metadata) throws InternalErrorException - { - //FIXME temp solution - // GWTProperties gwtProperties = new GWTProperties(metadata.getId(), metadata.getProperties()); + protected GWTProperties buildGWTProperties(Properties metadata) throws InternalErrorException { + // FIXME temp solution + // GWTProperties gwtProperties = new GWTProperties(metadata.getId(), + // metadata.getProperties()); return new GWTProperties(); } - /** * Builds the image url. * - * @param id the id - * @param currentGroupId the current group id - * @param currUserId the curr user id + * @param id + * the id + * @param currentGroupId + * the current group id + * @param currUserId + * the curr user id * @return the string */ - protected String buildImageUrl(String id, String currentGroupId, String currUserId) - { + protected String buildImageUrl(String id, String currentGroupId, String currUserId) { return buildImageServiceUrl(id, ImageRequestType.IMAGE, currentGroupId, currUserId); } - - /** * Builds the thumbnail url. * - * @param id the id - * @param currentGroupId the current group id - * @param currUserId the curr user id + * @param id + * the id + * @param currentGroupId + * the current group id + * @param currUserId + * the curr user id * @return the string */ - protected String buildThumbnailUrl(String id, String currentGroupId, String currUserId) - { + protected String buildThumbnailUrl(String id, String currentGroupId, String currUserId) { return buildImageServiceUrl(id, ImageRequestType.THUMBNAIL, currentGroupId, currUserId); } - /** * Builds the image service url. * - * @param id the id - * @param requestType the request type - * @param currentGroupId the current group id read from PortalContext - * @param currUserId the curr user id + * @param id + * the id + * @param requestType + * the request type + * @param currentGroupId + * the current group id read from PortalContext + * @param currUserId + * the curr user id * @return the string */ - protected String buildImageServiceUrl(String id, ImageRequestType requestType, String currentGroupId, String currUserId){ + protected String buildImageServiceUrl(String id, ImageRequestType requestType, String currentGroupId, + String currUserId) { StringBuilder sb = new StringBuilder(); sb.append(IMAGE_SERVICE_URL); sb.append("?id="); sb.append(id); sb.append("&type="); sb.append(requestType.toString()); - sb.append("&"+ConstantsExplorer.CURRENT_CONTEXT_ID+"="); + sb.append("&" + ConstantsExplorer.CURRENT_CONTEXT_ID + "="); sb.append(currentGroupId); - // sb.append("&"+ConstantsExplorer.CURRENT_USER_ID+"="); - // sb.append(currUserId); + // sb.append("&"+ConstantsExplorer.CURRENT_USER_ID+"="); + // sb.append(currUserId); sb.append("&random="); sb.append(UUID.randomUUID().toString()); return sb.toString(); @@ -286,94 +315,78 @@ public class GWTWorkspaceBuilder { /** * Builds the gwt workspace image. * - * @param item the item - * @param isInteralImage the is interal image - * @param fullDetails the full details - * @param currentGroupId the current group id - * @param currentUserId the current user id + * @param item + * the item + * @param isInteralImage + * the is interal image + * @param fullDetails + * the full details + * @param currentGroupId + * the current group id + * @param currentUserId + * the current user id * @return the GWT workspace item - * @throws InternalErrorException the internal error exception + * @throws InternalErrorException + * the internal error exception */ @SuppressWarnings("unchecked") - protected GWTWorkspaceItem buildGWTWorkspaceImage(WorkspaceItem item, boolean isInteralImage, boolean fullDetails, String currentGroupId, String currentUserId) throws InternalErrorException - { + protected GWTWorkspaceItem buildGWTWorkspaceImage(WorkspaceItem item, boolean isInteralImage, boolean fullDetails, + String currentGroupId, String currentUserId) throws InternalErrorException { GWTWorkspaceItem gwtImage; GWTProperties gwtProperties = buildGWTProperties(item.getProperties()); // - if(isInteralImage){ + if (isInteralImage) { - GCubeItem image = (GCubeItem) item; //Cast OLD Image Document + GCubeItem image = (GCubeItem) item; // Cast OLD Image Document - List links = (List) new XStream().fromXML(image.getProperties().getPropertyValue(NodeProperty.ALTERNATIVES.toString())); - List parts = (List) new XStream().fromXML(image.getProperties().getPropertyValue(NodeProperty.PARTS.toString())); - Map metadatas = (Map) new XStream().fromXML(image.getProperties().getPropertyValue(NodeProperty.METADATA.toString())); + List links = (List) new XStream() + .fromXML(image.getProperties().getPropertyValue(NodeProperty.ALTERNATIVES.toString())); + List parts = (List) new XStream() + .fromXML(image.getProperties().getPropertyValue(NodeProperty.PARTS.toString())); + Map metadatas = (Map) new XStream() + .fromXML(image.getProperties().getPropertyValue(NodeProperty.METADATA.toString())); Map gwtmetadatas = getMetadatas(metadatas, image.getId()); - gwtImage = new GWTImageDocument( - toDate(image.getCreationTime()), - image.getId(), - gwtProperties, - image.getName(), - image.getOwner().getPortalLogin(), - image.getDescription(), + gwtImage = new GWTImageDocument(toDate(image.getCreationTime()), image.getId(), gwtProperties, + image.getName(), image.getOwner().getPortalLogin(), image.getDescription(), toDate(image.getLastModificationTime()), - GWTWorkspaceItemAction.valueOf(image.getLastAction().toString()), - null, + GWTWorkspaceItemAction.valueOf(image.getLastAction().toString()), null, buildImageUrl(image.getId(), currentGroupId, currentUserId), buildThumbnailUrl(image.getId(), currentGroupId, currentUserId), Integer.parseInt(image.getProperties().getPropertyValue(NodeProperty.IMAGE_WIDTH.toString())), Integer.parseInt(image.getProperties().getPropertyValue(NodeProperty.IMAGE_HEIGHT.toString())), Integer.parseInt(image.getProperties().getPropertyValue(NodeProperty.THUMBNAIL_WIDTH.toString())), Integer.parseInt(image.getProperties().getPropertyValue(NodeProperty.THUMBNAIL_HEIGHT.toString())), - -1, - image.getLength(), - image.getMimeType(), - image.getProperties().getPropertyValue(NodeProperty.OID.toString()), - gwtmetadatas, + -1, image.getLength(), image.getMimeType(), + image.getProperties().getPropertyValue(NodeProperty.OID.toString()), gwtmetadatas, new LinkedHashMap(), - image.getProperties().getPropertyValue(NodeProperty.COLLECTION_NAME.toString()), - links.size(), + image.getProperties().getPropertyValue(NodeProperty.COLLECTION_NAME.toString()), links.size(), parts.size()); } - else{ + else { - ExternalImage image = (ExternalImage) item; //Cast External Document + ExternalImage image = (ExternalImage) item; // Cast External + // Document - if(fullDetails){ + if (fullDetails) { - gwtImage = new GWTExternalImage( - toDate(image.getCreationTime()), - image.getId(), - gwtProperties, - image.getName(), - image.getOwner().getPortalLogin(), - image.getDescription(), + gwtImage = new GWTExternalImage(toDate(image.getCreationTime()), image.getId(), gwtProperties, + image.getName(), image.getOwner().getPortalLogin(), image.getDescription(), toDate(image.getLastModificationTime()), - GWTWorkspaceItemAction.valueOf(image.getLastAction().toString()), - null, //parent + GWTWorkspaceItemAction.valueOf(image.getLastAction().toString()), null, // parent buildImageUrl(image.getId(), currentGroupId, currentUserId), - buildThumbnailUrl(image.getId(), currentGroupId, currentUserId), - image.getWidth(), - image.getHeight(), - image.getLength(), - image.getThumbnailWidth(), - image.getThumbnailHeight(), - -1, + buildThumbnailUrl(image.getId(), currentGroupId, currentUserId), image.getWidth(), + image.getHeight(), image.getLength(), image.getThumbnailWidth(), image.getThumbnailHeight(), -1, image.getMimeType()); - }else{ + } else { gwtImage = new GWTExternalImage(image.getId(), image.getName(), buildImageUrl(image.getId(), currentGroupId, currentUserId), - buildThumbnailUrl(image.getId(), currentGroupId, currentUserId), - image.getWidth(), - image.getHeight(), - image.getLength(), - image.getThumbnailWidth(), - image.getThumbnailHeight(), - -1, + buildThumbnailUrl(image.getId(), currentGroupId, currentUserId), image.getWidth(), + image.getHeight(), image.getLength(), image.getThumbnailWidth(), image.getThumbnailHeight(), -1, image.getMimeType()); } } @@ -383,113 +396,96 @@ public class GWTWorkspaceBuilder { /** * Builds the gwt external url. * - * @param url the url - * @param parent the parent + * @param url + * the url + * @param parent + * the parent * @return the GWT external url - * @throws InternalErrorException the internal error exception + * @throws InternalErrorException + * the internal error exception */ - protected GWTExternalUrl buildGWTExternalUrl(ExternalUrl url, GWTWorkspaceFolder parent) throws InternalErrorException - { + protected GWTExternalUrl buildGWTExternalUrl(ExternalUrl url, GWTWorkspaceFolder parent) + throws InternalErrorException { GWTProperties gwtProperties = buildGWTProperties(url.getProperties()); - GWTExternalUrl gwtUrl = new GWTExternalUrl( - toDate(url.getCreationTime()), - url.getId(), - gwtProperties, - url.getName(), - url.getOwner().getPortalLogin(), - url.getDescription(), - toDate(url.getLastModificationTime()), - GWTWorkspaceItemAction.valueOf(url.getLastAction().toString()), - parent, - url.getLength(), - url.getUrl()); + GWTExternalUrl gwtUrl = new GWTExternalUrl(toDate(url.getCreationTime()), url.getId(), gwtProperties, + url.getName(), url.getOwner().getPortalLogin(), url.getDescription(), + toDate(url.getLastModificationTime()), GWTWorkspaceItemAction.valueOf(url.getLastAction().toString()), + parent, url.getLength(), url.getUrl()); return gwtUrl; } - /** * Builds the gwt worspace url. * - * @param item the item - * @param isInternalUrl the is internal url - * @param fullDetails the full details + * @param item + * the item + * @param isInternalUrl + * the is internal url + * @param fullDetails + * the full details * @return the GWT workspace item - * @throws InternalErrorException the internal error exception + * @throws InternalErrorException + * the internal error exception */ @SuppressWarnings("unchecked") - protected GWTWorkspaceItem buildGWTWorspaceUrl(WorkspaceItem item, boolean isInternalUrl, boolean fullDetails) throws InternalErrorException - { + protected GWTWorkspaceItem buildGWTWorspaceUrl(WorkspaceItem item, boolean isInternalUrl, boolean fullDetails) + throws InternalErrorException { GWTWorkspaceItem gwtUrl = null; GWTProperties gwtProperties = buildGWTProperties(item.getProperties()); - if(isInternalUrl){ + if (isInternalUrl) { - GCubeItem document = (GCubeItem) item; //Cast OLD UrlDocument - // UrlDocument document = (UrlDocument) item; //Cast - List links = (List) new XStream().fromXML(document.getProperties().getPropertyValue(NodeProperty.ALTERNATIVES.toString())); - List parts = (List) new XStream().fromXML(document.getProperties().getPropertyValue(NodeProperty.PARTS.toString())); - Map metadatas = (Map) new XStream().fromXML(document.getProperties().getPropertyValue(NodeProperty.METADATA.toString())); + GCubeItem document = (GCubeItem) item; // Cast OLD UrlDocument + // UrlDocument document = (UrlDocument) item; //Cast + List links = (List) new XStream() + .fromXML(document.getProperties().getPropertyValue(NodeProperty.ALTERNATIVES.toString())); + List parts = (List) new XStream() + .fromXML(document.getProperties().getPropertyValue(NodeProperty.PARTS.toString())); + Map metadatas = (Map) new XStream() + .fromXML(document.getProperties().getPropertyValue(NodeProperty.METADATA.toString())); Map gwtmetadatas = getMetadatas(metadatas, document.getId()); - gwtUrl = new GWTUrlDocument( - toDate(document.getCreationTime()), - document.getId(), - gwtProperties, - document.getName(), - document.getOwner().getPortalLogin(), - document.getDescription(), + gwtUrl = new GWTUrlDocument(toDate(document.getCreationTime()), document.getId(), gwtProperties, + document.getName(), document.getOwner().getPortalLogin(), document.getDescription(), toDate(document.getLastModificationTime()), - GWTWorkspaceItemAction.valueOf(document.getLastAction().toString()), - null, - document.getLength(), - document.getProperties().getPropertyValue(NodeProperty.OID.toString()), - document.getMimeType(), - gwtmetadatas, - new LinkedHashMap(), - document.getProperties().getPropertyValue(NodeProperty.COLLECTION_NAME.toString()), - links.size(), - parts.size(), - document.getProperties().getPropertyValue(NodeProperty.URL.toString())); - } - else{ + GWTWorkspaceItemAction.valueOf(document.getLastAction().toString()), null, document.getLength(), + document.getProperties().getPropertyValue(NodeProperty.OID.toString()), document.getMimeType(), + gwtmetadatas, new LinkedHashMap(), + document.getProperties().getPropertyValue(NodeProperty.COLLECTION_NAME.toString()), links.size(), + parts.size(), document.getProperties().getPropertyValue(NodeProperty.URL.toString())); + } else { - ExternalUrl document = (ExternalUrl) item; //Cast + ExternalUrl document = (ExternalUrl) item; // Cast - if(fullDetails){ - gwtUrl = new GWTExternalUrl( - toDate(document.getCreationTime()), - document.getId(), - gwtProperties, - document.getName(), - document.getOwner().getPortalLogin(), - document.getDescription(), + if (fullDetails) { + gwtUrl = new GWTExternalUrl(toDate(document.getCreationTime()), document.getId(), gwtProperties, + document.getName(), document.getOwner().getPortalLogin(), document.getDescription(), toDate(document.getLastModificationTime()), - GWTWorkspaceItemAction.valueOf(document.getLastAction().toString()), - null, - document.getLength(), + GWTWorkspaceItemAction.valueOf(document.getLastAction().toString()), null, document.getLength(), document.getUrl()); - } - else + } else gwtUrl = new GWTExternalUrl(document.getUrl()); } return gwtUrl; } - /** * Gets the metadatas. * - * @param metadatas the metadatas - * @param documentId the document id + * @param metadatas + * the metadatas + * @param documentId + * the document id * @return the metadatas */ - protected Map getMetadatas(Map metadatas, String documentId) - { + protected Map getMetadatas(Map metadatas, + String documentId) { Map gwtmetadatas = new LinkedHashMap(); - for (Entry metadata : metadatas.entrySet()) gwtmetadatas.put(metadata.getKey(), getMetadata(metadata.getValue(), documentId)); + for (Entry metadata : metadatas.entrySet()) + gwtmetadatas.put(metadata.getKey(), getMetadata(metadata.getValue(), documentId)); return gwtmetadatas; } @@ -497,102 +493,119 @@ public class GWTWorkspaceBuilder { /** * Gets the metadata. * - * @param metadata the metadata - * @param documentId the document id + * @param metadata + * the metadata + * @param documentId + * the document id * @return the metadata */ - protected GWTDocumentMetadata getMetadata(DocumentMetadata metadata, String documentId) - { + protected GWTDocumentMetadata getMetadata(DocumentMetadata metadata, String documentId) { return new GWTDocumentMetadata(metadata.getSchemaName(), - "MetadataService?id="+documentId+"&schema="+metadata.getSchemaName()+"&type="+MetadataFormat.HTML, - "MetadataService?id="+documentId+"&schema="+metadata.getSchemaName()+"&type="+MetadataFormat.RAW_XML_AS_HTML, - "MetadataService?id="+documentId+"&schema="+metadata.getSchemaName()+"&type="+MetadataFormat.FORMATTED_XML); + "MetadataService?id=" + documentId + "&schema=" + metadata.getSchemaName() + "&type=" + + MetadataFormat.HTML, + "MetadataService?id=" + documentId + "&schema=" + metadata.getSchemaName() + "&type=" + + MetadataFormat.RAW_XML_AS_HTML, + "MetadataService?id=" + documentId + "&schema=" + metadata.getSchemaName() + "&type=" + + MetadataFormat.FORMATTED_XML); } /** * Builds the workspace file model root. * - * @param workspaceRoot the workspace root + * @param workspaceRoot + * the workspace root * @return the folder model - * @throws InternalErrorException the internal error exception + * @throws InternalErrorException + * the internal error exception */ public FolderModel buildWorkspaceFileModelRoot(WorkspaceFolder workspaceRoot) throws InternalErrorException { - logger.trace("workspace id: "+ workspaceRoot.getId()); - logger.trace("workspace name: "+ workspaceRoot.getName()); - logger.trace("workspace path "+ workspaceRoot.getPath()); + logger.trace("workspace id: " + workspaceRoot.getId()); + logger.trace("workspace name: " + workspaceRoot.getName()); + logger.trace("workspace path " + workspaceRoot.getPath()); - FolderModel root = new FolderModel(workspaceRoot.getId(),workspaceRoot.getName(),null, true, workspaceRoot.isShared(), false, workspaceRoot.isPublic()); + FolderModel root = new FolderModel(workspaceRoot.getId(), workspaceRoot.getName(), null, true, + workspaceRoot.isShared(), false, workspaceRoot.isPublic()); root.setIsRoot(true); return root; } - /** * Builds the gxt list file model item. * - * @param workspaceFolder the workspace folder - * @param parentFolderModel the parent folder model + * @param workspaceFolder + * the workspace folder + * @param parentFolderModel + * the parent folder model * @return the list - * @throws InternalErrorException the internal error exception + * @throws InternalErrorException + * the internal error exception */ - protected List buildGXTListFileModelItem(WorkspaceItem workspaceFolder, FileModel parentFolderModel) throws InternalErrorException { + protected List buildGXTListFileModelItem(WorkspaceItem workspaceFolder, FileModel parentFolderModel) + throws InternalErrorException { List listFileModel = new ArrayList(); @SuppressWarnings("unchecked") List listItems = (List) workspaceFolder.getChildren(); - if(listItems!=null) - logger.trace("HL return "+listItems.size()+ " items, converting..."); + if (listItems != null) + logger.trace("HL return " + listItems.size() + " items, converting..."); - //TEST TIME - // Long startTime = System.currentTimeMillis(); - // Long endTime = System.currentTimeMillis() - startTime; - // String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime)); - // logger.trace("tree getChildren() returning "+listItems.size()+" elements in " + time); - // startTime = System.currentTimeMillis(); + // TEST TIME + // Long startTime = System.currentTimeMillis(); + // Long endTime = System.currentTimeMillis() - startTime; + // String time = String.format("%d msc %d sec", endTime, + // TimeUnit.MILLISECONDS.toSeconds(endTime)); + // logger.trace("tree getChildren() returning "+listItems.size()+" + // elements in " + time); + // startTime = System.currentTimeMillis(); - for (WorkspaceItem item : listItems){ + for (WorkspaceItem item : listItems) { if (item.isFolder()) { - logger.debug("item: "+item.getName()+ "is root? " +item.isRoot()); - listFileModel.add(buildGXTFileModelItem(item,parentFolderModel)); + logger.debug("item: " + item.getName() + "is root? " + item.isRoot()); + listFileModel.add(buildGXTFileModelItem(item, parentFolderModel)); } } - //TEST TIME - // endTime = System.currentTimeMillis() - startTime; - // time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime)); - // logger.trace("tree gxt objects getChildren() returning "+listItems.size()+" elements in " + time); + // TEST TIME + // endTime = System.currentTimeMillis() - startTime; + // time = String.format("%d msc %d sec", endTime, + // TimeUnit.MILLISECONDS.toSeconds(endTime)); + // logger.trace("tree gxt objects getChildren() returning + // "+listItems.size()+" elements in " + time); return listFileModel; - // return buildGXTListFileModelItem((WorkspaceItem) workspaceFolder.getChildren(), parentFolderModel); + // return buildGXTListFileModelItem((WorkspaceItem) + // workspaceFolder.getChildren(), parentFolderModel); } - /** * Builds the gxt list file model item for attachs. * - * @param listWorspaceItems the list worspace items + * @param listWorspaceItems + * the list worspace items * @return the list - * @throws InternalErrorException the internal error exception + * @throws InternalErrorException + * the internal error exception */ - protected List buildGXTListFileModelItemForAttachs(List listWorspaceItems) throws InternalErrorException - { + protected List buildGXTListFileModelItemForAttachs(List listWorspaceItems) + throws InternalErrorException { List listFileModel = new ArrayList(); - for (WorkspaceItem item : listWorspaceItems){ + for (WorkspaceItem item : listWorspaceItems) { FileModel fileModel = null; switch (item.getType()) { - case FOLDER: fileModel = new FolderModel(item.getId(), item.getName(), true, false); - fileModel.setType(GXTFolderItemTypeEnum.FOLDER.getLabel()); - break; + case FOLDER: + fileModel = new FolderModel(item.getId(), item.getName(), true, false); + fileModel.setType(GXTFolderItemTypeEnum.FOLDER.getLabel()); + break; case FOLDER_ITEM: fileModel = new FileModel(item.getId(), item.getName(), false); @@ -603,7 +616,7 @@ public class GWTWorkspaceBuilder { case SHARED_FOLDER: WorkspaceSharedFolder shared = (WorkspaceSharedFolder) item; - String name = shared.isVreFolder()?shared.getDisplayName():item.getName(); + String name = shared.isVreFolder() ? shared.getDisplayName() : item.getName(); fileModel = new FolderModel(item.getId(), name, true, shared.isVreFolder()); fileModel.setShared(true); @@ -611,7 +624,7 @@ public class GWTWorkspaceBuilder { break; default: - logger.error("gxt conversion return null for item "+item.getName()); + logger.error("gxt conversion return null for item " + item.getName()); break; } @@ -620,52 +633,51 @@ public class GWTWorkspaceBuilder { return listFileModel; } - /** * Builds the gxt info contacts from portal logins. * - * @param listPortalLogin the list portal login + * @param listPortalLogin + * the list portal login * @return the list */ - public static List buildGxtInfoContactsFromPortalLogins(List listPortalLogin){ + public static List buildGxtInfoContactsFromPortalLogins(List listPortalLogin) { List listContact = new ArrayList(); - if(listPortalLogin!=null && listPortalLogin.size()>0){ + if (listPortalLogin != null && listPortalLogin.size() > 0) { for (String portalLogin : listPortalLogin) listContact.add(buildGxtInfoContactFromPortalLogin(portalLogin)); } - logger.debug("buildGxtInfoContactsFromPortalLogins return: "+ listContact.size()); + logger.debug("buildGxtInfoContactsFromPortalLogins return: " + listContact.size()); return listContact; } - /** * Builds the gxt info contact from portal login. * - * @param portalLogin the portal login + * @param portalLogin + * the portal login * @return the info contact model */ - public static InfoContactModel buildGxtInfoContactFromPortalLogin(String portalLogin){ + public static InfoContactModel buildGxtInfoContactFromPortalLogin(String portalLogin) { - if(portalLogin==null){ + if (portalLogin == null) { logger.warn("portal login is null, return empty"); portalLogin = ""; } - return new InfoContactModel(portalLogin, portalLogin, UserUtil.getUserFullName(portalLogin), false); + return new InfoContactModel(portalLogin, portalLogin, UserUtil.getUserFullName(portalLogin), "", false); } - - /** * Builds the gxt info contact from portal login test mode. * - * @param listPortalLogin the list portal login + * @param listPortalLogin + * the list portal login * @return the list */ - public static List buildGxtInfoContactFromPortalLoginTestMode(List listPortalLogin){ + public static List buildGxtInfoContactFromPortalLoginTestMode(List listPortalLogin) { List listContact = new ArrayList(); @@ -675,24 +687,25 @@ public class GWTWorkspaceBuilder { return listContact; } - /** * Builds the gxt file model item. * - * @param item the item - * @param parentFolderModel the parent folder model + * @param item + * the item + * @param parentFolderModel + * the parent folder model * @return the file model - * @throws InternalErrorException the internal error exception + * @throws InternalErrorException + * the internal error exception */ - protected FileModel buildGXTFileModelItem(WorkspaceItem item, FileModel parentFolderModel) throws InternalErrorException - { - // logger.debug("buildGXTFileModelItem: "+item.getName()); + protected FileModel buildGXTFileModelItem(WorkspaceItem item, FileModel parentFolderModel) + throws InternalErrorException { + // logger.debug("buildGXTFileModelItem: "+item.getName()); FileModel fileModel = null; /* - if(parentFolderModel!=null) - parentFolderModel = parentFolderModel; + * if(parentFolderModel!=null) parentFolderModel = parentFolderModel; */ switch (item.getType()) { @@ -700,7 +713,7 @@ public class GWTWorkspaceBuilder { case FOLDER: boolean isPublic = ((WorkspaceFolder) item).isPublic(); fileModel = new FolderModel(item.getId(), item.getName(), parentFolderModel, true, false, false, isPublic); - if(isPublic) + if (isPublic) fileModel.setType(GXTFolderItemTypeEnum.FOLDER_PUBLIC.getLabel()); else fileModel.setType(GXTFolderItemTypeEnum.FOLDER.getLabel()); @@ -721,9 +734,10 @@ public class GWTWorkspaceBuilder { case SHARED_FOLDER: WorkspaceSharedFolder shared = (WorkspaceSharedFolder) item; isPublic = ((WorkspaceFolder) shared).isPublic(); - String name = shared.isVreFolder()?shared.getDisplayName():item.getName(); - fileModel = new FolderModel(item.getId(), name, parentFolderModel, true, true, shared.isVreFolder(), isPublic); - if(isPublic) + String name = shared.isVreFolder() ? shared.getDisplayName() : item.getName(); + fileModel = new FolderModel(item.getId(), name, parentFolderModel, true, true, shared.isVreFolder(), + isPublic); + if (isPublic) fileModel.setType(GXTFolderItemTypeEnum.FOLDER_SHARED_PUBLIC.toString()); else fileModel.setType(GXTFolderItemTypeEnum.FOLDER_SHARED.toString()); @@ -733,18 +747,20 @@ public class GWTWorkspaceBuilder { break; default: - logger.error("gxt conversion return null for item "+item.getName()); + logger.error("gxt conversion return null for item " + item.getName()); break; } - //SET SHARE POLICY - if(parentFolderModel!=null && parentFolderModel.isShared()){ + // SET SHARE POLICY + if (parentFolderModel != null && parentFolderModel.isShared()) { fileModel.setShared(true); - fileModel.setShareable(false); //UPDATED TO CHANGE PERMISSIONS TO SHARED SUBFOLDERS - }else if(parentFolderModel==null && item.isShared()){ //ADDED TO FIX #1808 + fileModel.setShareable(false); // UPDATED TO CHANGE PERMISSIONS TO + // SHARED SUBFOLDERS + } else if (parentFolderModel == null && item.isShared()) { // ADDED TO + // FIX #1808 fileModel.setShared(true); - if(item.getParent()!=null && item.getParent().isShared()) + if (item.getParent() != null && item.getParent().isShared()) fileModel.setShareable(false); } @@ -752,39 +768,46 @@ public class GWTWorkspaceBuilder { return fileModel; } - /** * Builds the gxt list file grid model item for search. * - * @param listSearchItems the list search items + * @param listSearchItems + * the list search items * @return the list - * @throws Exception the exception + * @throws Exception + * the exception */ - public List buildGXTListFileGridModelItemForSearch(List listSearchItems) throws Exception { + public List buildGXTListFileGridModelItemForSearch(List listSearchItems) + throws Exception { List listFileGridModel = new ArrayList(); FileModel parentFileModel = null; for (SearchItem item : listSearchItems) - listFileGridModel.add(buildGXTFileGridModelItemForSearch(item,parentFileModel)); + listFileGridModel.add(buildGXTFileGridModelItemForSearch(item, parentFileModel)); return listFileGridModel; } /** * Builds the gxt file grid model item for search. * - * @param item the item - * @param parentFileModel the parent file model + * @param item + * the item + * @param parentFileModel + * the parent file model * @return the file grid model - * @throws Exception the exception + * @throws Exception + * the exception */ - private FileGridModel buildGXTFileGridModelItemForSearch(SearchItem item, FileModel parentFileModel) throws Exception{ + private FileGridModel buildGXTFileGridModelItemForSearch(SearchItem item, FileModel parentFileModel) + throws Exception { FileGridModel fileGridModel = null; - try{ + try { switch (item.getType()) { case FOLDER: - fileGridModel = new FolderGridModel(item.getId(), item.getName(), toDate(item.getLastModified()), parentFileModel, -1, true, false,false, false); + fileGridModel = new FolderGridModel(item.getId(), item.getName(), toDate(item.getLastModified()), + parentFileModel, -1, true, false, false, false); fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER.getLabel()); fileGridModel.setShortcutCategory(GXTCategorySmartFolder.SMF_FOLDERS); fileGridModel.setShareable(true); @@ -792,46 +815,52 @@ public class GWTWorkspaceBuilder { case FOLDER_ITEM: SearchFolderItem folderItem = (SearchFolderItem) item; - fileGridModel = new FileGridModel(item.getId(), item.getName(), toDate(item.getLastModified()), parentFileModel, folderItem.getSize(), false, false); + fileGridModel = new FileGridModel(item.getId(), item.getName(), toDate(item.getLastModified()), + parentFileModel, folderItem.getSize(), false, false); fileGridModel = (FileGridModel) setFolderItemTypeForSearch(fileGridModel, folderItem); break; case SHARED_FOLDER: - //ATTENTION: SEARCH ITEM IS NOT CASTABLE AT WorkspaceSharedFolder - fileGridModel = new FolderGridModel(item.getId(), item.getName(), toDate(item.getLastModified()), parentFileModel, -1, true, true, item.isVreFolder(), false); + // ATTENTION: SEARCH ITEM IS NOT CASTABLE AT + // WorkspaceSharedFolder + fileGridModel = new FolderGridModel(item.getId(), item.getName(), toDate(item.getLastModified()), + parentFileModel, -1, true, true, item.isVreFolder(), false); fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER_SHARED.getLabel()); fileGridModel.setShortcutCategory(GXTCategorySmartFolder.SMF_SHARED_FOLDERS); fileGridModel.setShareable(true); break; default: - logger.error("gxt conversion return null for item "+item.getName()); + logger.error("gxt conversion return null for item " + item.getName()); break; } - if(parentFileModel!=null && parentFileModel.isShared()){ + if (parentFileModel != null && parentFileModel.isShared()) { fileGridModel.setShared(true); - fileGridModel.setShareable(false); //UPDATED TO CHANGE PERMISSIONS TO SHARED SUBFOLDERS + fileGridModel.setShareable(false); // UPDATED TO CHANGE + // PERMISSIONS TO SHARED + // SUBFOLDERS } - //OWNER - if(item.isShared()){ //IS READ FROM HL ONLY IF THE ITEM IS SHARED - fileGridModel.setShared(true); //TEMPORARY SOLUTION: ADDED TO FIX WRONG TYPE SearchFolderItem - String portalLogin = item.getOwner(); //IS PORTAL LOGIN - if(portalLogin!=null){ + // OWNER + if (item.isShared()) { // IS READ FROM HL ONLY IF THE ITEM IS SHARED + fileGridModel.setShared(true); // TEMPORARY SOLUTION: ADDED TO + // FIX WRONG TYPE + // SearchFolderItem + String portalLogin = item.getOwner(); // IS PORTAL LOGIN + if (portalLogin != null) { fileGridModel.setOwnerFullName(UserUtil.getUserFullName(portalLogin)); } - } - else{ - if(userLogged!=null) + } else { + if (userLogged != null) fileGridModel.setOwnerFullName(userLogged.getName()); } setSynchedThreddsStateFor(fileGridModel, scope, userLogged.getLogin()); return fileGridModel; - }catch (Exception e) { + } catch (Exception e) { logger.error("An error occurred in buildGXTFileGridModelItemForSearch:", e); throw new Exception(e); } @@ -840,22 +869,27 @@ public class GWTWorkspaceBuilder { /** * Builds the gxt list file grid model item. * - * @param listWorkspaceItems the list workspace items - * @param parentFileModel the parent file model + * @param listWorkspaceItems + * the list workspace items + * @param parentFileModel + * the parent file model * @return the list - * @throws InternalErrorException the internal error exception + * @throws InternalErrorException + * the internal error exception */ - public List buildGXTListFileGridModelItem(List listWorkspaceItems, FileModel parentFileModel) throws InternalErrorException{ + public List buildGXTListFileGridModelItem(List listWorkspaceItems, + FileModel parentFileModel) throws InternalErrorException { - Long startTime = System.currentTimeMillis(); + Long startTime = System.currentTimeMillis(); List listFileGridModel = new ArrayList(); for (WorkspaceItem item : listWorkspaceItems) - listFileGridModel.add(buildGXTFileGridModelItem(item,parentFileModel)); + listFileGridModel.add(buildGXTFileGridModelItem(item, parentFileModel)); Long endTime = System.currentTimeMillis() - startTime; String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime)); - logger.trace("##GRID FILLING: gxt grid objects getChildren() returning "+listWorkspaceItems.size()+" elements in " + time); + logger.trace("##GRID FILLING: gxt grid objects getChildren() returning " + listWorkspaceItems.size() + + " elements in " + time); return listFileGridModel; } @@ -863,22 +897,26 @@ public class GWTWorkspaceBuilder { /** * Builds the gxt file grid model item. * - * @param item the item - * @param parentFileModel the parent file model + * @param item + * the item + * @param parentFileModel + * the parent file model * @return the file grid model - * @throws InternalErrorException the internal error exception + * @throws InternalErrorException + * the internal error exception */ - public FileGridModel buildGXTFileGridModelItem(WorkspaceItem item, FileModel parentFileModel) throws InternalErrorException{ - + public FileGridModel buildGXTFileGridModelItem(WorkspaceItem item, FileModel parentFileModel) + throws InternalErrorException { FileGridModel fileGridModel = null; switch (item.getType()) { case FOLDER: - boolean isPublic = ((WorkspaceFolder)item).isPublic(); - fileGridModel = new FolderGridModel(item.getId(), item.getName(), toDate(item.getLastModificationTime()), parentFileModel, -1, true, false,false, isPublic); - if(isPublic) + boolean isPublic = ((WorkspaceFolder) item).isPublic(); + fileGridModel = new FolderGridModel(item.getId(), item.getName(), toDate(item.getLastModificationTime()), + parentFileModel, -1, true, false, false, isPublic); + if (isPublic) fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER_PUBLIC.getLabel().toString()); else fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER.getLabel().toString()); @@ -890,26 +928,28 @@ public class GWTWorkspaceBuilder { case FOLDER_ITEM: FolderItem folderItem = (FolderItem) item; - fileGridModel = new FileGridModel(item.getId(), item.getName(), toDate(item.getLastModificationTime()), parentFileModel, folderItem.getLength(), false, false); + fileGridModel = new FileGridModel(item.getId(), item.getName(), toDate(item.getLastModificationTime()), + parentFileModel, folderItem.getLength(), false, false); fileGridModel = (FileGridModel) setFolderItemType(fileGridModel, folderItem); - //ADDING VERSION NAME - // if (folderItem instanceof ExternalFile){ + // ADDING VERSION NAME + // if (folderItem instanceof ExternalFile){ // - // ExternalFile extFile = (ExternalFile) folderItem; - // WorkspaceVersion version = extFile.getCurrentVersion(); - // fileGridModel.setVersionName(version!=null?version.getName():null); - // } + // ExternalFile extFile = (ExternalFile) folderItem; + // WorkspaceVersion version = extFile.getCurrentVersion(); + // fileGridModel.setVersionName(version!=null?version.getName():null); + // } break; case SHARED_FOLDER: WorkspaceSharedFolder shared = (WorkspaceSharedFolder) item; - isPublic = ((WorkspaceFolder)shared).isPublic(); - String name = shared.isVreFolder()?shared.getDisplayName():item.getName(); - fileGridModel = new FolderGridModel(item.getId(), name, toDate(item.getLastModificationTime()), parentFileModel, -1, true, true, shared.isVreFolder(), isPublic); + isPublic = ((WorkspaceFolder) shared).isPublic(); + String name = shared.isVreFolder() ? shared.getDisplayName() : item.getName(); + fileGridModel = new FolderGridModel(item.getId(), name, toDate(item.getLastModificationTime()), + parentFileModel, -1, true, true, shared.isVreFolder(), isPublic); - if(isPublic) + if (isPublic) fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER_SHARED_PUBLIC.getLabel().toString()); else fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER_SHARED.getLabel().toString()); @@ -920,29 +960,32 @@ public class GWTWorkspaceBuilder { break; default: - logger.error("gxt conversion return null for item "+item.getName()); + logger.error("gxt conversion return null for item " + item.getName()); break; } - if(parentFileModel!=null && parentFileModel.isShared()){ + if (parentFileModel != null && parentFileModel.isShared()) { fileGridModel.setShared(true); - fileGridModel.setShareable(false); //UPDATED TO CHANGE PERMISSIONS TO SHARED SUBFOLDERS + fileGridModel.setShareable(false); // UPDATED TO CHANGE PERMISSIONS + // TO SHARED SUBFOLDERS } - //OWNER - if(item.isShared()){ //IS READ FROM HL ONLY IF THE ITEM IS SHARED - fileGridModel.setShared(true); //NOT REMOVE IT IS IMPORTAT SEE #1459 + // OWNER + if (item.isShared()) { // IS READ FROM HL ONLY IF THE ITEM IS SHARED + fileGridModel.setShared(true); // NOT REMOVE IT IS IMPORTAT SEE + // #1459 User owner = item.getOwner(); - if(owner!=null){ - // System.out.println("++++reading owner"); + if (owner != null) { + // System.out.println("++++reading owner"); String portalLogin = owner.getPortalLogin(); fileGridModel.setOwnerFullName(UserUtil.getUserFullName(portalLogin)); } - } - else{ - if(userLogged!=null) - // fileGridModel.setOwner(new InfoContactModel(userLogged.getId(), userLogged.getLogin(), userLogged.getName())); + } else { + if (userLogged != null) + // fileGridModel.setOwner(new + // InfoContactModel(userLogged.getId(), userLogged.getLogin(), + // userLogged.getName())); fileGridModel.setOwnerFullName(userLogged.getName()); } @@ -953,21 +996,25 @@ public class GWTWorkspaceBuilder { /** * Sets the folder item type for search. * - * @param fileModel the file model - * @param searchFolderItem the search folder item + * @param fileModel + * the file model + * @param searchFolderItem + * the search folder item * @return the file model */ - protected FileModel setFolderItemTypeForSearch(FileModel fileModel, SearchFolderItem searchFolderItem){ + protected FileModel setFolderItemTypeForSearch(FileModel fileModel, SearchFolderItem searchFolderItem) { - if(searchFolderItem.getFolderItemType()==null){ - logger.trace("Search folder item type is null for "+searchFolderItem.getId() + " name: "+searchFolderItem.getName()); - //FOR DEBUG - // System.out.println("Search folder item type is null for "+searchFolderItem.getId() + " name: "+searchFolderItem.getName()); + if (searchFolderItem.getFolderItemType() == null) { + logger.trace("Search folder item type is null for " + searchFolderItem.getId() + " name: " + + searchFolderItem.getName()); + // FOR DEBUG + // System.out.println("Search folder item type is null for + // "+searchFolderItem.getId() + " name: + // "+searchFolderItem.getName()); return fileModel; } - switch(searchFolderItem.getFolderItemType()) - { + switch (searchFolderItem.getFolderItemType()) { case EXTERNAL_IMAGE: fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_IMAGE); fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_IMAGES); @@ -1042,14 +1089,15 @@ public class GWTWorkspaceBuilder { /** * Sets the folder item type. * - * @param fileModel the file model - * @param worspaceFolderItem the worspace folder item + * @param fileModel + * the file model + * @param worspaceFolderItem + * the worspace folder item * @return the file model */ - protected FileModel setFolderItemType(FileModel fileModel, FolderItem worspaceFolderItem){ + protected FileModel setFolderItemType(FileModel fileModel, FolderItem worspaceFolderItem) { - switch(worspaceFolderItem.getFolderItemType()) - { + switch (worspaceFolderItem.getFolderItemType()) { case EXTERNAL_IMAGE: fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_IMAGE); fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_IMAGES); @@ -1095,23 +1143,24 @@ public class GWTWorkspaceBuilder { case IMAGE_DOCUMENT: fileModel.setFolderItemType(GXTFolderItemTypeEnum.IMAGE_DOCUMENT); fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_IMAGES); - // ImageDocument imgDoc = (ImageDocument) worspaceFolderItem; - GCubeItem imgDoc = (GCubeItem) worspaceFolderItem; //Cast GCubeItem + // ImageDocument imgDoc = (ImageDocument) worspaceFolderItem; + GCubeItem imgDoc = (GCubeItem) worspaceFolderItem; // Cast GCubeItem try { fileModel.setType(imgDoc.getMimeType()); } catch (InternalErrorException e) { - logger.error("IMAGE_DOCUMENT InternalErrorException when getting MimeType on "+fileModel.getIdentifier()); + logger.error( + "IMAGE_DOCUMENT InternalErrorException when getting MimeType on " + fileModel.getIdentifier()); } break; case DOCUMENT: fileModel.setFolderItemType(GXTFolderItemTypeEnum.DOCUMENT); fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_DOCUMENTS); - // Document doc = (Document) worspaceFolderItem; - GCubeItem doc = (GCubeItem) worspaceFolderItem; //Cast GCubeItem + // Document doc = (Document) worspaceFolderItem; + GCubeItem doc = (GCubeItem) worspaceFolderItem; // Cast GCubeItem try { fileModel.setType(doc.getMimeType()); } catch (InternalErrorException e) { - logger.error("DOCUMENT InternalErrorException when getting MimeType on "+fileModel.getIdentifier()); + logger.error("DOCUMENT InternalErrorException when getting MimeType on " + fileModel.getIdentifier()); } break; case URL_DOCUMENT: @@ -1139,17 +1188,19 @@ public class GWTWorkspaceBuilder { /** * Gets the public link for folder item. * - * @param worspaceFolderItem the worspace folder item + * @param worspaceFolderItem + * the worspace folder item * @return the publi link for folder item - * @throws InternalErrorException the internal error exception + * @throws InternalErrorException + * the internal error exception */ - public String getPublicLinkForFolderItem(FolderItem worspaceFolderItem) throws InternalErrorException{ + public String getPublicLinkForFolderItem(FolderItem worspaceFolderItem) throws InternalErrorException { - if(worspaceFolderItem==null) + if (worspaceFolderItem == null) return ""; - try{ - switch(worspaceFolderItem.getFolderItemType()){ + try { + switch (worspaceFolderItem.getFolderItemType()) { case EXTERNAL_IMAGE: return ((ExternalImage) worspaceFolderItem).getPublicLink(); case EXTERNAL_FILE: @@ -1169,7 +1220,8 @@ public class GWTWorkspaceBuilder { case PDF_DOCUMENT: break; case IMAGE_DOCUMENT: - GCubeItem imgDoc = (GCubeItem) worspaceFolderItem; //Cast GCubeItem + GCubeItem imgDoc = (GCubeItem) worspaceFolderItem; // Cast + // GCubeItem return imgDoc.getPublicLink(false); case DOCUMENT: break; @@ -1181,30 +1233,30 @@ public class GWTWorkspaceBuilder { return ""; } - }catch (Exception e) { - logger.error("an error occurred when get public link for item: "+worspaceFolderItem.getName()); + } catch (Exception e) { + logger.error("an error occurred when get public link for item: " + worspaceFolderItem.getName()); return ""; } return ""; } - - /** * Gets the storage id for folder item. * - * @param worspaceFolderItem the worspace folder item + * @param worspaceFolderItem + * the worspace folder item * @return the storage id for folder item - * @throws InternalErrorException the internal error exception + * @throws InternalErrorException + * the internal error exception */ - public String getStorageIDForFolderItem(FolderItem worspaceFolderItem) throws InternalErrorException{ + public String getStorageIDForFolderItem(FolderItem worspaceFolderItem) throws InternalErrorException { - if(worspaceFolderItem==null) + if (worspaceFolderItem == null) return ""; - try{ - switch(worspaceFolderItem.getFolderItemType()){ + try { + switch (worspaceFolderItem.getFolderItemType()) { case EXTERNAL_IMAGE: return ((ExternalImage) worspaceFolderItem).getStorageID(); case EXTERNAL_FILE: @@ -1224,7 +1276,8 @@ public class GWTWorkspaceBuilder { case PDF_DOCUMENT: break; case IMAGE_DOCUMENT: - GCubeItem imgDoc = (GCubeItem) worspaceFolderItem; //Cast GCubeItem + GCubeItem imgDoc = (GCubeItem) worspaceFolderItem; // Cast + // GCubeItem return imgDoc.getStorageID(); case DOCUMENT: break; @@ -1236,8 +1289,8 @@ public class GWTWorkspaceBuilder { return ""; } - }catch (Exception e) { - logger.error("an error occurred when get public link for item: "+worspaceFolderItem.getName()); + } catch (Exception e) { + logger.error("an error occurred when get public link for item: " + worspaceFolderItem.getName()); return ""; } @@ -1247,36 +1300,43 @@ public class GWTWorkspaceBuilder { /** * Builds the gxt folder model item. * - * @param wsFolder the ws folder - * @param parent the parent + * @param wsFolder + * the ws folder + * @param parent + * the parent * @return the folder model - * @throws InternalErrorException the internal error exception + * @throws InternalErrorException + * the internal error exception */ - public FolderModel buildGXTFolderModelItem(WorkspaceFolder wsFolder, FileModel parent) throws InternalErrorException { + public FolderModel buildGXTFolderModelItem(WorkspaceFolder wsFolder, FileModel parent) + throws InternalErrorException { logger.debug("buildGXTFolderModelItem..."); String name = ""; - //MANAGEMENT SHARED FOLDER NAME - if(wsFolder.isShared() && wsFolder.getType().equals(WorkspaceItemType.SHARED_FOLDER)){ + // MANAGEMENT SHARED FOLDER NAME + if (wsFolder.isShared() && wsFolder.getType().equals(WorkspaceItemType.SHARED_FOLDER)) { WorkspaceSharedFolder shared = (WorkspaceSharedFolder) wsFolder; - name = shared.isVreFolder()?shared.getDisplayName():wsFolder.getName(); - }else + name = shared.isVreFolder() ? shared.getDisplayName() : wsFolder.getName(); + } else name = wsFolder.getName(); - //MANAGEMENT SPECIAL FOLDER - // if(wsFolder.getName().compareTo("MySpecialFolders")==0 && wsFolder.getParent()!=null && wsFolder.getParent().isRoot()){ - // WorkspaceSharedFolder shared = (WorkspaceSharedFolder) wsFolder; - // name = shared.isVreFolder()?shared.getDisplayName():wsFolder.getName(); - // }else - // name = wsFolder.getName(); + // MANAGEMENT SPECIAL FOLDER + // if(wsFolder.getName().compareTo("MySpecialFolders")==0 && + // wsFolder.getParent()!=null && wsFolder.getParent().isRoot()){ + // WorkspaceSharedFolder shared = (WorkspaceSharedFolder) wsFolder; + // name = + // shared.isVreFolder()?shared.getDisplayName():wsFolder.getName(); + // }else + // name = wsFolder.getName(); - FolderModel folder = new FolderModel(wsFolder.getId(), name, parent, true, wsFolder.isShared(), false, wsFolder.isPublic()); + FolderModel folder = new FolderModel(wsFolder.getId(), name, parent, true, wsFolder.isShared(), false, + wsFolder.isPublic()); folder.setShareable(true); folder.setDescription(wsFolder.getDescription()); - // folder.setOwner(wsFolder.getOwner()); + // folder.setOwner(wsFolder.getOwner()); - if(parent != null && parent.isShared()){ + if (parent != null && parent.isShared()) { folder.setShared(true); folder.setShareable(false); } @@ -1285,53 +1345,62 @@ public class GWTWorkspaceBuilder { } /** - * TODO ********TEMPORARY SOLUTION HL MUST MANAGE SPECIAL FOLDER AS WORKSPACESPECIALFOLDER**** - * REMOVE THIS METHOD AND ADDING INSTANCE OF AT buildGXTFolderModelItem. + * TODO ********TEMPORARY SOLUTION HL MUST MANAGE SPECIAL FOLDER AS + * WORKSPACESPECIALFOLDER**** REMOVE THIS METHOD AND ADDING INSTANCE OF AT + * buildGXTFolderModelItem. * - * @param wsFolder the ws folder - * @param parent the parent - * @param specialFolderName the special folder name + * @param wsFolder + * the ws folder + * @param parent + * the parent + * @param specialFolderName + * the special folder name * @return the folder model - * @throws InternalErrorException the internal error exception + * @throws InternalErrorException + * the internal error exception */ - public FolderModel buildGXTFolderModelItemHandleSpecialFolder(WorkspaceFolder wsFolder, FileModel parent, String specialFolderName) throws InternalErrorException { + public FolderModel buildGXTFolderModelItemHandleSpecialFolder(WorkspaceFolder wsFolder, FileModel parent, + String specialFolderName) throws InternalErrorException { String name = ""; - logger.debug("buildGXTFolderModelItemHandleSpecialFolder to folder: "+wsFolder.getName()); - //MANAGEMENT SHARED FOLDER NAME - if(wsFolder.isShared() && wsFolder.getType().equals(WorkspaceItemType.SHARED_FOLDER)){ + logger.debug("buildGXTFolderModelItemHandleSpecialFolder to folder: " + wsFolder.getName()); + // MANAGEMENT SHARED FOLDER NAME + if (wsFolder.isShared() && wsFolder.getType().equals(WorkspaceItemType.SHARED_FOLDER)) { logger.debug("MANAGEMENT SHARED Folder name.."); WorkspaceSharedFolder shared = (WorkspaceSharedFolder) wsFolder; - logger.debug("shared.isVreFolder(): "+shared.isVreFolder()); - name = shared.isVreFolder()?shared.getDisplayName():wsFolder.getName(); + logger.debug("shared.isVreFolder(): " + shared.isVreFolder()); + name = shared.isVreFolder() ? shared.getDisplayName() : wsFolder.getName(); /* - if(shared.isVreFolder()) - logger.debug("shared.getDisplayName(): "+shared.getDisplayName()); + * if(shared.isVreFolder()) + * logger.debug("shared.getDisplayName(): "+shared.getDisplayName()) + * ; */ - //MANAGEMENT SPECIAL FOLDER - }else if(wsFolder.getName().compareTo(ConstantsExplorer.MY_SPECIAL_FOLDERS)==0 && wsFolder.getParent()!=null && wsFolder.getParent().isRoot()){ - //MANAGEMENT SPECIAL FOLDER - logger.debug("MANAGEMENT SPECIAL FOLDER NAME REWRITING AS: "+specialFolderName); - if(specialFolderName!=null && !specialFolderName.isEmpty()) + // MANAGEMENT SPECIAL FOLDER + } else if (wsFolder.getName().compareTo(ConstantsExplorer.MY_SPECIAL_FOLDERS) == 0 + && wsFolder.getParent() != null && wsFolder.getParent().isRoot()) { + // MANAGEMENT SPECIAL FOLDER + logger.debug("MANAGEMENT SPECIAL FOLDER NAME REWRITING AS: " + specialFolderName); + if (specialFolderName != null && !specialFolderName.isEmpty()) name = specialFolderName; else name = wsFolder.getName(); - }else{ + } else { logger.debug("MANAGEMENT Base Folder name.."); name = wsFolder.getName(); } - logger.debug("Name is: "+name); + logger.debug("Name is: " + name); - FolderModel folder = new FolderModel(wsFolder.getId(), name, parent, true, wsFolder.isShared(), false, wsFolder.isPublic()); + FolderModel folder = new FolderModel(wsFolder.getId(), name, parent, true, wsFolder.isShared(), false, + wsFolder.isPublic()); folder.setShareable(true); folder.setIsRoot(wsFolder.isRoot()); folder.setDescription(wsFolder.getDescription()); - // folder.setOwner(wsFolder.getOwner()); + // folder.setOwner(wsFolder.getOwner()); - if(parent != null && parent.isShared()){ + if (parent != null && parent.isShared()) { folder.setShared(true); folder.setShareable(false); } @@ -1341,25 +1410,21 @@ public class GWTWorkspaceBuilder { /** * Builds the gwt workspace file details. * - * @param wsItem the ws item - * @param item the item + * @param wsItem + * the ws item + * @param item + * the item * @return the file details model - * @throws InternalErrorException the internal error exception + * @throws InternalErrorException + * the internal error exception */ - public FileDetailsModel buildGWTWorkspaceFileDetails(WorkspaceItem wsItem, FileModel item) throws InternalErrorException { + public FileDetailsModel buildGWTWorkspaceFileDetails(WorkspaceItem wsItem, FileModel item) + throws InternalErrorException { - FileDetailsModel fileDetailsModel = new FileDetailsModel( - wsItem.getId(), - wsItem.getName(), - wsItem.getPath(), - toDate(wsItem.getCreationTime()), - item.getParentFileModel(), - 0,//size - item.isDirectory(), - wsItem.getDescription(), - toDate(wsItem.getLastModificationTime()), - buildGXTInfoContactModel(wsItem.getOwner()), - wsItem.isShared()); + FileDetailsModel fileDetailsModel = new FileDetailsModel(wsItem.getId(), wsItem.getName(), wsItem.getPath(), + toDate(wsItem.getCreationTime()), item.getParentFileModel(), 0, // size + item.isDirectory(), wsItem.getDescription(), toDate(wsItem.getLastModificationTime()), + buildGXTInfoContactModel(wsItem.getOwner()), wsItem.isShared()); return fileDetailsModel; } @@ -1367,11 +1432,13 @@ public class GWTWorkspaceBuilder { /** * Gets the folder item type category. * - * @param item the item + * @param item + * the item * @return the folder item type category - * @throws InternalErrorException the internal error exception + * @throws InternalErrorException + * the internal error exception */ - protected GXTCategorySmartFolder getFolderItemTypeCategory(SearchItem item) throws InternalErrorException{ + protected GXTCategorySmartFolder getFolderItemTypeCategory(SearchItem item) throws InternalErrorException { switch (item.getType()) { @@ -1382,8 +1449,7 @@ public class GWTWorkspaceBuilder { case FOLDER_ITEM: SearchFolderItem folderItem = (SearchFolderItem) item; - switch(folderItem.getFolderItemType()) - { + switch (folderItem.getFolderItemType()) { case EXTERNAL_IMAGE: return GXTCategorySmartFolder.SMF_IMAGES; case EXTERNAL_FILE: @@ -1417,7 +1483,7 @@ public class GWTWorkspaceBuilder { } default: - logger.error("gxt conversion return null for item "+item.getName()); + logger.error("gxt conversion return null for item " + item.getName()); return GXTCategorySmartFolder.SMF_UNKNOWN; } @@ -1426,72 +1492,82 @@ public class GWTWorkspaceBuilder { /** * Filter list file grid model item by category. * - * @param listSearchItem the list search item - * @param category the category + * @param listSearchItem + * the list search item + * @param category + * the category * @return the list - * @throws Exception the exception + * @throws Exception + * the exception */ - public List filterListFileGridModelItemByCategory(List listSearchItem, GXTCategorySmartFolder category) throws Exception { + public List filterListFileGridModelItemByCategory(List listSearchItem, + GXTCategorySmartFolder category) throws Exception { List filteredList = new ArrayList(); - logger.trace("filterListFileGridModelItemByCategory - Category:" + category + "listSearchItem size " + listSearchItem.size()); - for(SearchItem searchItem: listSearchItem){ + logger.trace("filterListFileGridModelItemByCategory - Category:" + category + "listSearchItem size " + + listSearchItem.size()); + for (SearchItem searchItem : listSearchItem) { logger.trace("wsItem: " + searchItem.getName()); - if(category.equals(getFolderItemTypeCategory(searchItem))) - filteredList.add(buildGXTFileGridModelItemForSearch(searchItem,null)); + if (category.equals(getFolderItemTypeCategory(searchItem))) + filteredList.add(buildGXTFileGridModelItemForSearch(searchItem, null)); } return filteredList; } - /** * Builds the gxt list smart folder model. * - * @param listWorkspaceSmartFolder the list workspace smart folder + * @param listWorkspaceSmartFolder + * the list workspace smart folder * @return the list - * @throws Exception the exception + * @throws Exception + * the exception */ - public List buildGXTListSmartFolderModel(List listWorkspaceSmartFolder) throws Exception { + public List buildGXTListSmartFolderModel(List listWorkspaceSmartFolder) + throws Exception { List listSmartFolder = new ArrayList(); - for(WorkspaceSmartFolder workspaceFolder : listWorkspaceSmartFolder) + for (WorkspaceSmartFolder workspaceFolder : listWorkspaceSmartFolder) listSmartFolder.add(buildGXTSmartFolderModel(workspaceFolder, "")); return listSmartFolder; } - /** * Builds the gxt smart folder model. * - * @param wsFolder the ws folder - * @param query the query + * @param wsFolder + * the ws folder + * @param query + * the query * @return the smart folder model - * @throws Exception the exception + * @throws Exception + * the exception */ public SmartFolderModel buildGXTSmartFolderModel(WorkspaceSmartFolder wsFolder, String query) throws Exception { - SmartFolderModel smartFolderModel = new SmartFolderModel( - wsFolder.getId(), - wsFolder.getName(), - query); + SmartFolderModel smartFolderModel = new SmartFolderModel(wsFolder.getId(), wsFolder.getName(), query); - logger.trace("in return SmartFolder: " + smartFolderModel.getIdentifier() + " " + smartFolderModel.getName() + " " + smartFolderModel.getQuery()); + logger.trace("in return SmartFolder: " + smartFolderModel.getIdentifier() + " " + smartFolderModel.getName() + + " " + smartFolderModel.getQuery()); return smartFolderModel; } /** * Builds the gxt list scope model. * - * @param listFilteredScopes the list filtered scopes - * @param mapPortalScopes the map portal scopes + * @param listFilteredScopes + * the list filtered scopes + * @param mapPortalScopes + * the map portal scopes * @return the list */ - public List buildGXTListScopeModel(List listFilteredScopes, Map mapPortalScopes) { + public List buildGXTListScopeModel(List listFilteredScopes, + Map mapPortalScopes) { List listScopeModel = new ArrayList(); - for(String scope: listFilteredScopes) - listScopeModel.add(new ScopeModel(mapPortalScopes.get(scope),scope)); + for (String scope : listFilteredScopes) + listScopeModel.add(new ScopeModel(mapPortalScopes.get(scope), scope)); return listScopeModel; @@ -1500,29 +1576,34 @@ public class GWTWorkspaceBuilder { /** * Builds the gxt list contacts model from user model. * - * @param listUsers the list users + * @param listUsers + * the list users * @return the list - * @throws InternalErrorException the internal error exception + * @throws InternalErrorException + * the internal error exception */ - public List buildGXTListContactsModelFromUserModel(List listUsers) throws InternalErrorException { + public List buildGXTListContactsModelFromUserModel(List listUsers) + throws InternalErrorException { List listContactsModel = new ArrayList(); - if(listUsers==null) + if (listUsers == null) return listContactsModel; - logger.trace("List size returned from Portal VO is: "+ listUsers.size()); + logger.trace("List size returned from Portal VO is: " + listUsers.size()); logger.trace("Building list contact model list user model"); for (GCubeUser userModel : listUsers) { String fullName = userModel.getFullname(); - if(fullName!=null && !fullName.isEmpty()) - listContactsModel.add(new InfoContactModel(userModel.getUserId()+"", userModel.getScreenName(), fullName, false)); + if (fullName != null && !fullName.isEmpty()) + listContactsModel.add(new InfoContactModel(userModel.getUserId() + "", userModel.getScreenName(), + fullName, extractDomainFromEmail(userModel.getEmail()), false)); else - logger.trace("buildGXTListContactsModel is not returning user: "+userModel.getScreenName()+ "because name is null or empty"); + logger.trace("buildGXTListContactsModel is not returning user: " + userModel.getScreenName() + + "because name is null or empty"); } - logger.trace("List contact model completed, return " +listContactsModel.size()+" contacts"); + logger.trace("List contact model completed, return " + listContactsModel.size() + " contacts"); return listContactsModel; } @@ -1530,99 +1611,110 @@ public class GWTWorkspaceBuilder { /** * Builds the gxt list contacts model from gcube group. * - * @param list the list + * @param list + * the list * @return the list - * @throws InternalErrorException the internal error exception + * @throws InternalErrorException + * the internal error exception */ - public List buildGXTListContactsModelFromGcubeGroup(List list) throws InternalErrorException { + public List buildGXTListContactsModelFromGcubeGroup(List list) + throws InternalErrorException { List listContactsModel = new ArrayList(); - if(list==null) + if (list == null) return listContactsModel; - logger.trace("List size returned from GcubeGroup is: "+ list.size()); + logger.trace("List size returned from GcubeGroup is: " + list.size()); logger.trace("Building list contact model..."); - for (GCubeGroup group : list){ - try{ + for (GCubeGroup group : list) { + try { String groupDN = group.getDisplayName(); - if(groupDN==null || groupDN.isEmpty()) + if (groupDN == null || groupDN.isEmpty()) groupDN = group.getName(); - if(group.getName()== null || group.getName().isEmpty()) - logger.warn("Skipping group with null or empty name "+group); - else{ - InfoContactModel contact = new InfoContactModel(group.getName(), group.getName(), groupDN, true); - logger.trace("Adding group "+contact); + if (group.getName() == null || group.getName().isEmpty()) + logger.warn("Skipping group with null or empty name " + group); + else { + InfoContactModel contact = new InfoContactModel(group.getName(), group.getName(), groupDN, "", + true); + logger.trace("Adding group " + contact); listContactsModel.add(contact); } - }catch (InternalErrorException e) { - logger.warn("Dispaly name is not available to group "+group); - logger.warn("Adding get name property "+group.getName()); + } catch (InternalErrorException e) { + logger.warn("Dispaly name is not available to group " + group); + logger.warn("Adding get name property " + group.getName()); - if(group.getName()== null || group.getName().isEmpty()) - logger.warn("Skipping group with null or empty name "+group); + if (group.getName() == null || group.getName().isEmpty()) + logger.warn("Skipping group with null or empty name " + group); else - listContactsModel.add(new InfoContactModel(group.getName(), group.getName(), group.getName(), true)); + listContactsModel + .add(new InfoContactModel(group.getName(), group.getName(), group.getName(), "", true)); } } - logger.trace("List GCubeGroup contact model completed, return " +listContactsModel.size()+" contacts"); + logger.trace("List GCubeGroup contact model completed, return " + listContactsModel.size() + " contacts"); return listContactsModel; } - /** * Builds the list login from contanct model. * - * @param listContactsModel the list contacts model + * @param listContactsModel + * the list contacts model * @return list of portal logins - * @throws InternalErrorException the internal error exception + * @throws InternalErrorException + * the internal error exception */ - public List buildListLoginFromContanctModel(List listContactsModel) throws InternalErrorException { + public List buildListLoginFromContanctModel(List listContactsModel) + throws InternalErrorException { List listPortalLogin = new ArrayList(); - for(InfoContactModel contact: listContactsModel){ + for (InfoContactModel contact : listContactsModel) { listPortalLogin.add(contact.getLogin()); } return listPortalLogin; } - /** * Builds the gxt list message model for grid. * - * @param listMessages the list messages - * @param typeMessages the type messages + * @param listMessages + * the list messages + * @param typeMessages + * the type messages * @return the list - * @throws InternalErrorException the internal error exception + * @throws InternalErrorException + * the internal error exception */ - public List buildGXTListMessageModelForGrid(List listMessages, String typeMessages) throws InternalErrorException { + public List buildGXTListMessageModelForGrid(List listMessages, String typeMessages) + throws InternalErrorException { List listMessageModel = new ArrayList(); - - for(WorkspaceMessage mess: listMessages){ + for (WorkspaceMessage mess : listMessages) { List listAttachs = mess.getAttachments(); List listAttachsNames = new ArrayList(); - logger.trace("IN SERVER MESSAGE TYPE: " +typeMessages); - logger.trace("subject " + mess.getSubject()); + logger.trace("IN SERVER MESSAGE TYPE: " + typeMessages); + logger.trace("subject " + mess.getSubject()); - if(listAttachs!=null){ - for(WorkspaceItem attach: listAttachs){ + if (listAttachs != null) { + for (WorkspaceItem attach : listAttachs) { listAttachsNames.add(attach.getName()); - logger.trace("Received attach: "+ attach.getName() + " " +attach.getId()); + logger.trace("Received attach: " + attach.getName() + " " + attach.getId()); } } - listMessageModel.add(new MessageModel(mess.getId(), mess.getSubject(), buildGXTInfoContactModel(mess.getSender()), toDate(mess.getSendTime()), listAttachsNames, typeMessages, mess.isRead())); + listMessageModel + .add(new MessageModel(mess.getId(), mess.getSubject(), buildGXTInfoContactModel(mess.getSender()), + toDate(mess.getSendTime()), listAttachsNames, typeMessages, mess.isRead())); } return listMessageModel; @@ -1631,30 +1723,40 @@ public class GWTWorkspaceBuilder { /** * Builds the gxt message model. * - * @param mess the mess - * @param listWorkspaceItems the list workspace items - * @param messageType the message type + * @param mess + * the mess + * @param listWorkspaceItems + * the list workspace items + * @param messageType + * the message type * @return the message model - * @throws InternalErrorException the internal error exception + * @throws InternalErrorException + * the internal error exception */ - public MessageModel buildGXTMessageModel(WorkspaceMessage mess, List listWorkspaceItems, String messageType) throws InternalErrorException { + public MessageModel buildGXTMessageModel(WorkspaceMessage mess, List listWorkspaceItems, + String messageType) throws InternalErrorException { List listAttachs = buildGXTListFileModelItemForAttachs(listWorkspaceItems); - return new MessageModel(mess.getId(), mess.getSubject(), buildGXTInfoContactModel(mess.getSender()), toDate(mess.getSendTime()), mess.getBody(), listAttachs, mess.getAddresses(), messageType, mess.isRead()); + return new MessageModel(mess.getId(), mess.getSubject(), buildGXTInfoContactModel(mess.getSender()), + toDate(mess.getSendTime()), mess.getBody(), listAttachs, mess.getAddresses(), messageType, + mess.isRead()); } /** * Builds the gxt info contact model. * - * @param user the user + * @param user + * the user * @return InfoContactModel - * @throws InternalErrorException the internal error exception + * @throws InternalErrorException + * the internal error exception */ - public InfoContactModel buildGXTInfoContactModel(User user) throws InternalErrorException{ + public InfoContactModel buildGXTInfoContactModel(User user) throws InternalErrorException { - if(user!=null) - return new InfoContactModel(user.getId(), user.getPortalLogin(), UserUtil.getUserFullName(user.getPortalLogin()), false); + if (user != null) + return new InfoContactModel(user.getId(), user.getPortalLogin(), + UserUtil.getUserFullName(user.getPortalLogin()), "", false); return new InfoContactModel(); } @@ -1662,16 +1764,19 @@ public class GWTWorkspaceBuilder { /** * Builds the gxt accounting item. * - * @param accoutings the accoutings - * @param gxtEntryType the gxt entry type + * @param accoutings + * the accoutings + * @param gxtEntryType + * the gxt entry type * @return the list */ - public List buildGXTAccountingItem(List accoutings, GxtAccountingEntryType gxtEntryType) { + public List buildGXTAccountingItem(List accoutings, + GxtAccountingEntryType gxtEntryType) { List listAccFields = new ArrayList(); - if(accoutings!=null){ - logger.trace("accoutings size "+accoutings.size()+ ", converting..."); + if (accoutings != null) { + logger.trace("accoutings size " + accoutings.size() + ", converting..."); for (AccountingEntry accountingEntry : accoutings) { @@ -1686,20 +1791,25 @@ public class GWTWorkspaceBuilder { case CREATE: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.CREATE)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.CREATE)) { AccountingEntryCreate create = (AccountingEntryCreate) accountingEntry; af.setOperation(GxtAccountingEntryType.CREATE); - // af.setDescription(GxtAccountingEntryType.CREATE.getName() + " by "+user.getName()); + // af.setDescription(GxtAccountingEntryType.CREATE.getName() + // + " by "+user.getName()); String msg = ""; - if(create.getItemName()==null || create.getItemName().isEmpty()) - msg = GxtAccountingEntryType.CREATE.getId() + " by "+user.getName(); - else{ + if (create.getItemName() == null || create.getItemName().isEmpty()) + msg = GxtAccountingEntryType.CREATE.getId() + " by " + user.getName(); + else { - if(create.getVersion()==null) - msg = create.getItemName() + " " + GxtAccountingEntryType.CREATE.getName() + " by "+user.getName(); + if (create.getVersion() == null) + msg = create.getItemName() + " " + GxtAccountingEntryType.CREATE.getName() + " by " + + user.getName(); else - msg = create.getItemName() + " v. "+create.getVersion()+" "+ GxtAccountingEntryType.CREATE.getName() + " by "+user.getName(); + msg = create.getItemName() + " v. " + create.getVersion() + " " + + GxtAccountingEntryType.CREATE.getName() + " by " + user.getName(); } af.setDescription(msg); @@ -1709,21 +1819,25 @@ public class GWTWorkspaceBuilder { case READ: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.READ)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.READ)) { AccountingEntryRead read = (AccountingEntryRead) accountingEntry; af.setOperation(GxtAccountingEntryType.READ); - af.setDescription(read.getItemName() + " " + GxtAccountingEntryType.READ.getName() + " by "+user.getName()); + af.setDescription(read.getItemName() + " " + GxtAccountingEntryType.READ.getName() + " by " + + user.getName()); String msg = ""; - if(read.getItemName()==null || read.getItemName().isEmpty()) - msg = GxtAccountingEntryType.READ.getId() + " by "+user.getName(); - else{ + if (read.getItemName() == null || read.getItemName().isEmpty()) + msg = GxtAccountingEntryType.READ.getId() + " by " + user.getName(); + else { - if(read.getVersion()==null) - msg = read.getItemName() + " " + GxtAccountingEntryType.READ.getName() + " by "+user.getName(); + if (read.getVersion() == null) + msg = read.getItemName() + " " + GxtAccountingEntryType.READ.getName() + " by " + + user.getName(); else - msg = read.getItemName() + " v."+read.getVersion() +" "+ GxtAccountingEntryType.READ.getName() + " by "+user.getName(); + msg = read.getItemName() + " v." + read.getVersion() + " " + + GxtAccountingEntryType.READ.getName() + " by " + user.getName(); } af.setDescription(msg); @@ -1733,19 +1847,23 @@ public class GWTWorkspaceBuilder { case CUT: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.CUT)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.CUT)) { af.setOperation(GxtAccountingEntryType.CUT); AccountingEntryCut cut = (AccountingEntryCut) accountingEntry; String msg = ""; - if(cut.getItemName()==null || cut.getItemName().isEmpty()) - msg = GxtAccountingEntryType.CUT.getName() +" by "+user.getName(); - else{ - if(cut.getVersion()==null) - msg = cut.getItemName()+" "+GxtAccountingEntryType.CUT.getName() +" by "+user.getName(); + if (cut.getItemName() == null || cut.getItemName().isEmpty()) + msg = GxtAccountingEntryType.CUT.getName() + " by " + user.getName(); + else { + if (cut.getVersion() == null) + msg = cut.getItemName() + " " + GxtAccountingEntryType.CUT.getName() + " by " + + user.getName(); else - msg = cut.getItemName()+" v."+cut.getVersion()+" "+GxtAccountingEntryType.CUT.getName() +" by "+user.getName(); + msg = cut.getItemName() + " v." + cut.getVersion() + " " + + GxtAccountingEntryType.CUT.getName() + " by " + user.getName(); } af.setDescription(msg); @@ -1755,31 +1873,39 @@ public class GWTWorkspaceBuilder { case PASTE: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.PASTE)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.PASTE)) { af.setOperation(GxtAccountingEntryType.PASTE); AccountingEntryPaste paste = (AccountingEntryPaste) accountingEntry; - if(paste.getVersion()==null) - af.setDescription(GxtAccountingEntryType.PASTE.getName() + " from "+paste.getFromPath()+" by "+user.getName()); + if (paste.getVersion() == null) + af.setDescription(GxtAccountingEntryType.PASTE.getName() + " from " + paste.getFromPath() + + " by " + user.getName()); else - af.setDescription(GxtAccountingEntryType.PASTE.getName() + " v. "+paste.getVersion()+" from "+paste.getFromPath()+" by "+user.getName()); + af.setDescription(GxtAccountingEntryType.PASTE.getName() + " v. " + paste.getVersion() + + " from " + paste.getFromPath() + " by " + user.getName()); } break; case REMOVAL: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.REMOVE)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.REMOVE)) { af.setOperation(GxtAccountingEntryType.REMOVE); AccountingEntryRemoval rem = (AccountingEntryRemoval) accountingEntry; - String msg = rem.getItemName()==null || rem.getItemName().isEmpty()?"":rem.getItemName()+" "; + String msg = rem.getItemName() == null || rem.getItemName().isEmpty() ? "" + : rem.getItemName() + " "; - if(rem.getVersion()==null) - msg+= GxtAccountingEntryType.REMOVE.getName() +" by "+user.getName(); + if (rem.getVersion() == null) + msg += GxtAccountingEntryType.REMOVE.getName() + " by " + user.getName(); else - msg+= GxtAccountingEntryType.REMOVE.getName() +" v."+rem.getVersion()+" by "+user.getName(); + msg += GxtAccountingEntryType.REMOVE.getName() + " v." + rem.getVersion() + " by " + + user.getName(); af.setDescription(msg); } @@ -1787,15 +1913,20 @@ public class GWTWorkspaceBuilder { case RENAMING: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.RENAME)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.RENAME)) { af.setOperation(GxtAccountingEntryType.RENAME); AccountingEntryRenaming ren = (AccountingEntryRenaming) accountingEntry; - String msg = ren.getOldItemName()==null || ren.getOldItemName().isEmpty()?"":ren.getOldItemName()+" "; - if(ren.getVersion()==null) - msg+= GxtAccountingEntryType.RENAME.getName() +" to "+ ren.getNewItemName()+ " by "+user.getName(); + String msg = ren.getOldItemName() == null || ren.getOldItemName().isEmpty() ? "" + : ren.getOldItemName() + " "; + if (ren.getVersion() == null) + msg += GxtAccountingEntryType.RENAME.getName() + " to " + ren.getNewItemName() + " by " + + user.getName(); else - msg+= " v."+ren.getVersion() +" "+GxtAccountingEntryType.RENAME.getName() +" to "+ ren.getNewItemName()+ " by "+user.getName(); + msg += " v." + ren.getVersion() + " " + GxtAccountingEntryType.RENAME.getName() + " to " + + ren.getNewItemName() + " by " + user.getName(); af.setDescription(msg); } @@ -1803,15 +1934,19 @@ public class GWTWorkspaceBuilder { case ADD: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.ADD)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.ADD)) { af.setOperation(GxtAccountingEntryType.ADD); AccountingEntryAdd acc = (AccountingEntryAdd) accountingEntry; - String msg = acc.getItemName()==null || acc.getItemName().isEmpty()?"":acc.getItemName()+" "; - if(acc.getVersion()==null) - msg+=GxtAccountingEntryType.ADD.getName()+ " by "+user.getName(); + String msg = acc.getItemName() == null || acc.getItemName().isEmpty() ? "" + : acc.getItemName() + " "; + if (acc.getVersion() == null) + msg += GxtAccountingEntryType.ADD.getName() + " by " + user.getName(); else - msg+=" v."+acc.getVersion()+ " "+GxtAccountingEntryType.ADD.getName()+ " by "+user.getName(); + msg += " v." + acc.getVersion() + " " + GxtAccountingEntryType.ADD.getName() + " by " + + user.getName(); af.setDescription(msg); } @@ -1819,15 +1954,19 @@ public class GWTWorkspaceBuilder { case UPDATE: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.UPDATE)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.UPDATE)) { af.setOperation(GxtAccountingEntryType.UPDATE); AccountingEntryUpdate upd = (AccountingEntryUpdate) accountingEntry; - String msg = upd.getItemName()==null || upd.getItemName().isEmpty()?"":upd.getItemName()+" "; - if(upd.getVersion()==null) - msg+=GxtAccountingEntryType.UPDATE.getName()+" by "+user.getName(); + String msg = upd.getItemName() == null || upd.getItemName().isEmpty() ? "" + : upd.getItemName() + " "; + if (upd.getVersion() == null) + msg += GxtAccountingEntryType.UPDATE.getName() + " by " + user.getName(); else - msg+=" v."+upd.getVersion()+" "+GxtAccountingEntryType.UPDATE.getName()+" by "+user.getName(); + msg += " v." + upd.getVersion() + " " + GxtAccountingEntryType.UPDATE.getName() + " by " + + user.getName(); af.setDescription(msg); } @@ -1835,20 +1974,23 @@ public class GWTWorkspaceBuilder { case SHARE: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.SHARE)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.SHARE)) { af.setOperation(GxtAccountingEntryType.SHARE); AccountingEntryShare acc = (AccountingEntryShare) accountingEntry; String msg = ""; - if(acc.getItemName()==null || acc.getItemName().isEmpty()) - msg = user.getName() + " "+GxtAccountingEntryType.SHARE.getName()+ " workspace folder"; + if (acc.getItemName() == null || acc.getItemName().isEmpty()) + msg = user.getName() + " " + GxtAccountingEntryType.SHARE.getName() + " workspace folder"; else - msg = user.getName() + " "+GxtAccountingEntryType.SHARE.getName()+ " workspace folder "+acc.getItemName(); + msg = user.getName() + " " + GxtAccountingEntryType.SHARE.getName() + " workspace folder " + + acc.getItemName(); - if(acc.getMembers()!=null && acc.getMembers().size()>0) - msg+=" with "+UserUtil.separateFullNameToCommaForPortalLogin(acc.getMembers()); + if (acc.getMembers() != null && acc.getMembers().size() > 0) + msg += " with " + UserUtil.separateFullNameToCommaForPortalLogin(acc.getMembers()); af.setDescription(msg); } @@ -1856,28 +1998,35 @@ public class GWTWorkspaceBuilder { case UNSHARE: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.UNSHARE)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.UNSHARE)) { af.setOperation(GxtAccountingEntryType.UNSHARE); AccountingEntryUnshare uns = (AccountingEntryUnshare) accountingEntry; - String msg = uns.getItemName()==null || uns.getItemName().isEmpty()?"":uns.getItemName()+" "; - msg+=GxtAccountingEntryType.UNSHARE.getName()+" by "+user.getName(); + String msg = uns.getItemName() == null || uns.getItemName().isEmpty() ? "" + : uns.getItemName() + " "; + msg += GxtAccountingEntryType.UNSHARE.getName() + " by " + user.getName(); af.setDescription(msg); } break; case RESTORE: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.RESTORE)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.RESTORE)) { af.setOperation(GxtAccountingEntryType.RESTORE); AccountingEntryRestore acc = (AccountingEntryRestore) accountingEntry; - String msg = acc.getItemName()==null || acc.getItemName().isEmpty()?"":acc.getItemName()+" "; + String msg = acc.getItemName() == null || acc.getItemName().isEmpty() ? "" + : acc.getItemName() + " "; - if(acc.getVersion()==null) - msg+=GxtAccountingEntryType.RESTORE.getName()+" by "+user.getName(); + if (acc.getVersion() == null) + msg += GxtAccountingEntryType.RESTORE.getName() + " by " + user.getName(); else - msg+=" v."+acc.getVersion()+" "+GxtAccountingEntryType.RESTORE.getName() +" by "+user.getName(); + msg += " v." + acc.getVersion() + " " + GxtAccountingEntryType.RESTORE.getName() + " by " + + user.getName(); af.setDescription(msg); } @@ -1885,12 +2034,15 @@ public class GWTWorkspaceBuilder { case DISABLED_PUBLIC_ACCESS: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.DISABLED_PUBLIC_ACCESS)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.DISABLED_PUBLIC_ACCESS)) { af.setOperation(GxtAccountingEntryType.DISABLED_PUBLIC_ACCESS); AccountingEntryDisabledPublicAccess acc = (AccountingEntryDisabledPublicAccess) accountingEntry; - String msg = acc.getItemName()==null || acc.getItemName().isEmpty()?"":acc.getItemName()+" "; - msg+=GxtAccountingEntryType.DISABLED_PUBLIC_ACCESS.getName()+" by "+user.getName(); + String msg = acc.getItemName() == null || acc.getItemName().isEmpty() ? "" + : acc.getItemName() + " "; + msg += GxtAccountingEntryType.DISABLED_PUBLIC_ACCESS.getName() + " by " + user.getName(); af.setDescription(msg); } @@ -1898,12 +2050,15 @@ public class GWTWorkspaceBuilder { case ENABLED_PUBLIC_ACCESS: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.ENABLED_PUBLIC_ACCESS)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.ENABLED_PUBLIC_ACCESS)) { af.setOperation(GxtAccountingEntryType.ENABLED_PUBLIC_ACCESS); AccountingEntryEnabledPublicAccess acc = (AccountingEntryEnabledPublicAccess) accountingEntry; - String msg = acc.getItemName()==null || acc.getItemName().isEmpty()?"":acc.getItemName()+" "; - msg+=GxtAccountingEntryType.ENABLED_PUBLIC_ACCESS.getName()+" by "+user.getName(); + String msg = acc.getItemName() == null || acc.getItemName().isEmpty() ? "" + : acc.getItemName() + " "; + msg += GxtAccountingEntryType.ENABLED_PUBLIC_ACCESS.getName() + " by " + user.getName(); af.setDescription(msg); } @@ -1917,24 +2072,24 @@ public class GWTWorkspaceBuilder { listAccFields.add(af); } } - logger.debug("get accounting readers converting completed - returning size "+listAccFields.size()); + logger.debug("get accounting readers converting completed - returning size " + listAccFields.size()); return listAccFields; } - /** * Builds the gxt accounting item from readers. * - * @param readers the readers + * @param readers + * the readers * @return the list */ public List buildGXTAccountingItemFromReaders(List readers) { List listAccFields = new ArrayList(); - if(readers!=null){ + if (readers != null) { for (AccountingEntryRead accReader : readers) { @@ -1946,10 +2101,11 @@ public class GWTWorkspaceBuilder { af.setOperation(GxtAccountingEntryType.READ); String msg = ""; - if(accReader.getItemName()==null || accReader.getItemName().isEmpty()) - msg = GxtAccountingEntryType.READ.getName() + " by "+user.getName(); + if (accReader.getItemName() == null || accReader.getItemName().isEmpty()) + msg = GxtAccountingEntryType.READ.getName() + " by " + user.getName(); else - msg = accReader.getItemName() + " " + GxtAccountingEntryType.READ.getName() + " by "+user.getName(); + msg = accReader.getItemName() + " " + GxtAccountingEntryType.READ.getName() + " by " + + user.getName(); af.setDescription(msg); listAccFields.add(af); @@ -1960,52 +2116,51 @@ public class GWTWorkspaceBuilder { return listAccFields; } - /** * Sets the contex info. * - * @param infoContactModel the info contact model - * @param scope the scope + * @param infoContactModel + * the info contact model + * @param scope + * the scope */ public void setContexInfo(InfoContactModel infoContactModel, String scope) { this.userLogged = infoContactModel; this.scope = scope; } - - - /** * Builds the gxt list trash content. * - * @param trash the trash + * @param trash + * the trash * @return the list - * @throws Exception the exception + * @throws Exception + * the exception */ - public List buildGXTListTrashContent(WorkspaceTrashFolder trash) throws Exception - { + public List buildGXTListTrashContent(WorkspaceTrashFolder trash) throws Exception { List trashContent = trash.listTrashItems(); - logger.info("Converting trash content, size is: "+ trashContent.size()); + logger.info("Converting trash content, size is: " + trashContent.size()); List listFileModel = new ArrayList(); try { for (WorkspaceTrashItem trashedItem : trashContent) - try{ + try { FileTrashedModel cti = buildGXTTrashModelItem(trashedItem); listFileModel.add(cti); - }catch (Exception e) { + } catch (Exception e) { logger.warn("Error in server buildGXTListTrashContent, skipping conversion of trashedItem", e); } } catch (Exception e) { logger.error("Error in server buildGXTListTrashContent", e); - String error = ConstantsExplorer.SERVER_ERROR +" get Trash content. "+e.getMessage(); + String error = ConstantsExplorer.SERVER_ERROR + " get Trash content. " + e.getMessage(); throw new Exception(error); } - logger.info("Returning trash content as FileTrashedModel, size is: "+ trashContent.size()); + logger.info("Returning trash content as FileTrashedModel, size is: " + trashContent.size()); return listFileModel; @@ -2014,39 +2169,42 @@ public class GWTWorkspaceBuilder { /** * Builds the gxt trash model item. * - * @param trashedItem the trashed item + * @param trashedItem + * the trashed item * @return the file trashed model - * @throws InternalErrorException the internal error exception + * @throws InternalErrorException + * the internal error exception */ - public FileTrashedModel buildGXTTrashModelItem(WorkspaceTrashItem trashedItem) throws InternalErrorException{ + public FileTrashedModel buildGXTTrashModelItem(WorkspaceTrashItem trashedItem) throws InternalErrorException { FileTrashedModel fileTrashModel = new FileTrashedModel(); fileTrashModel.setName(trashedItem.getName()); - fileTrashModel.setIdentifier(trashedItem.getId()); //TODO + fileTrashModel.setIdentifier(trashedItem.getId()); // TODO - //SETTING PARENT + // SETTING PARENT FileModel oldParent = new FileModel(trashedItem.getOriginalParentId(), "", true); fileTrashModel.setOrginalPath(trashedItem.getDeletedFrom()); fileTrashModel.setParentFileModel(oldParent); - //SETTING DELETED BY + // SETTING DELETED BY InfoContactModel deleteUser = buildGxtInfoContactFromPortalLogin(trashedItem.getDeletedBy()); fileTrashModel.setDeleteUser(deleteUser); - //SETTING MIME TYPE + // SETTING MIME TYPE fileTrashModel.setType(trashedItem.getMimeType()); - //SETTING IS DIRECTORY + // SETTING IS DIRECTORY fileTrashModel.setIsDirectory(trashedItem.isFolder()); - //SETTING DELETE DATE + // SETTING DELETE DATE fileTrashModel.setDeleteDate(toDate(trashedItem.getDeletedTime())); fileTrashModel.setShared(false); - logger.debug("Converting return trash item: "+fileTrashModel.getName() +" id: "+fileTrashModel.getIdentifier()); + logger.debug( + "Converting return trash item: " + fileTrashModel.getName() + " id: " + fileTrashModel.getIdentifier()); return fileTrashModel; @@ -2055,46 +2213,49 @@ public class GWTWorkspaceBuilder { /** * Builds the gxt trash model item by id. * - * @param itemId the item id - * @param trash the trash + * @param itemId + * the item id + * @param trash + * the trash * @return the file trashed model - * @throws InternalErrorException the internal error exception + * @throws InternalErrorException + * the internal error exception */ - public FileTrashedModel buildGXTTrashModelItemById(String itemId, WorkspaceTrashFolder trash) throws InternalErrorException{ + public FileTrashedModel buildGXTTrashModelItemById(String itemId, WorkspaceTrashFolder trash) + throws InternalErrorException { return null; } - /** * Gets the formatted html acl from ac ls. * - * @param aclOwner the acl owner + * @param aclOwner + * the acl owner * @return the formatted html of the ACLs */ public String getFormatHtmlACLFromACLs(Map> aclOwner) { String html = "
"; - logger.trace("Formatting "+aclOwner.size() +" ACL/s"); + logger.trace("Formatting " + aclOwner.size() + " ACL/s"); for (ACLType type : aclOwner.keySet()) { List listLogins = aclOwner.get(type); - html+=""+type+": "; - html+=""; + html += "" + type + ": "; + html += ""; for (String login : listLogins) { - logger.trace("Adding login "+login); + logger.trace("Adding login " + login); String fullName = UserUtil.getUserFullName(login); - if(fullName!=null && !fullName.isEmpty()) - html+=fullName+"; "; + if (fullName != null && !fullName.isEmpty()) + html += fullName + "; "; else - html+=login+"; "; + html += login + "; "; } - html+="
"; + html += "

"; } - html+="
"; - + html += ""; return html; } @@ -2102,27 +2263,28 @@ public class GWTWorkspaceBuilder { /** * returns dynamically the formated size. * - * @param size the size + * @param size + * the size * @return the string */ public static String formatFileSize(long size) { String formattedSize = null; double b = size; - double k = size/1024.0; - double m = size/1024.0/1024.0; - double g = size/1024.0/1024.0/1024.0; - double t = size/1024.0/1024.0/1024.0/1024.0; + double k = size / 1024.0; + double m = size / 1024.0 / 1024.0; + double g = size / 1024.0 / 1024.0 / 1024.0; + double t = size / 1024.0 / 1024.0 / 1024.0 / 1024.0; DecimalFormat dec = new DecimalFormat("0.00"); - if ( t>1 ) { + if (t > 1) { formattedSize = dec.format(t).concat(" TB"); - } else if ( g>1 ) { + } else if (g > 1) { formattedSize = dec.format(g).concat(" GB"); - } else if ( m>1 ) { + } else if (m > 1) { formattedSize = dec.format(m).concat(" MB"); - } else if ( k>1 ) { + } else if (k > 1) { formattedSize = dec.format(k).concat(" KB"); } else { formattedSize = dec.format(b).concat(" Bytes"); @@ -2134,53 +2296,55 @@ public class GWTWorkspaceBuilder { /** * Gets the item description for type by id. * - * @param item the item + * @param item + * the item * @return the item description for type by id - * @throws Exception the exception + * @throws Exception + * the exception */ public String getItemDescriptionForTypeById(WorkspaceItem item) throws Exception { - if(item==null) + if (item == null) throw new Exception("The item is null"); - logger.info("Getting ItemDescriptionById: "+item.getId()); + logger.info("Getting ItemDescriptionById: " + item.getId()); try { switch (item.getType()) { - case FOLDER:{ + case FOLDER: { WorkspaceFolder theFolder = (WorkspaceFolder) item; return theFolder.getDescription(); } - case SHARED_FOLDER:{ + case SHARED_FOLDER: { WorkspaceSharedFolder theFolder = (WorkspaceSharedFolder) item; return theFolder.getDescription(); } - case SMART_FOLDER:{ + case SMART_FOLDER: { WorkspaceSmartFolder theFolder = (WorkspaceSmartFolder) item; return theFolder.getDescription(); } - case TRASH_FOLDER:{ - WorkspaceTrashFolder theFolder = (WorkspaceTrashFolder) item; + case TRASH_FOLDER: { + WorkspaceTrashFolder theFolder = (WorkspaceTrashFolder) item; return ""; } - case TRASH_ITEM:{ + case TRASH_ITEM: { WorkspaceTrashItem tItem = (WorkspaceTrashItem) item; return tItem.getDescription(); } - default:{ //IS AN ITEM + default: { // IS AN ITEM return item.getDescription(); } } } catch (Exception e) { logger.error("Error in server ItemDescriptionForTypeById: ", e); - String error = ConstantsExplorer.SERVER_ERROR +" getting description for item id: "+item.getId(); + String error = ConstantsExplorer.SERVER_ERROR + " getting description for item id: " + item.getId(); throw new Exception(error); } } @@ -2188,20 +2352,23 @@ public class GWTWorkspaceBuilder { /** * Gets the format html gcube item properties. * - * @param item the item - * @return Format HTML. A DIV HTML containing gcube item properties. If item is a GcubeItem and contains properties return HTML, null otherwise + * @param item + * the item + * @return Format HTML. A DIV HTML containing gcube item properties. If item + * is a GcubeItem and contains properties return HTML, null + * otherwise */ public String getFormatHtmlGcubeItemProperties(WorkspaceItem item) { Map properties = getGcubeItemProperties(item); - if(properties!=null){ + if (properties != null) { - if(properties.size()==0){ + if (properties.size() == 0) { try { - logger.warn("Gcube Item Properties not found for item: "+item.getId()); + logger.warn("Gcube Item Properties not found for item: " + item.getId()); } catch (InternalErrorException e) { - //SILENT + // SILENT } return null; } @@ -2210,13 +2377,13 @@ public class GWTWorkspaceBuilder { for (String key : properties.keySet()) { String value = properties.get(key); - logger.trace("Getting property: ["+key+","+properties.get(key)+"]"); - html+=""+key+": "; - html+=""; - html+=value; - html+="
"; + logger.trace("Getting property: [" + key + "," + properties.get(key) + "]"); + html += "" + key + ": "; + html += ""; + html += value; + html += "
"; } - html+=""; + html += ""; return html; } @@ -2226,17 +2393,22 @@ public class GWTWorkspaceBuilder { /** * Gets the gcube item properties. * - * @param item the item + * @param item + * the item * @return the gcube item properties */ public Map getGcubeItemProperties(WorkspaceItem item) { - if(item instanceof GCubeItem){ + if (item instanceof GCubeItem) { GCubeItem gItem = (GCubeItem) item; try { - if(gItem.getProperties()!=null){ + if (gItem.getProperties() != null) { Map map = gItem.getProperties().getProperties(); - HashMap properties = new HashMap(map.size()); //TO PREVENT GWT SERIALIZATION ERROR + HashMap properties = new HashMap(map.size()); // TO + // PREVENT + // GWT + // SERIALIZATION + // ERROR for (String key : map.keySet()) properties.put(key, map.get(key)); @@ -2253,26 +2425,30 @@ public class GWTWorkspaceBuilder { /** * Sets the synched thredds state for. * - * @param fileModel the file model - * @param scope the scope - * @param username the username + * @param fileModel + * the file model + * @param scope + * the scope + * @param username + * the username * @return the file model */ protected FileModel setSynchedThreddsStateFor(FileModel fileModel, String scope, String username) { try { - if(fileModel.isDirectory()) { + if (fileModel.isDirectory()) { ScopeProvider.instance.set(scope); - Sync_Status status = WorkspaceThreddsSynchronize.getInstance().getSynchedStatusFromItemProperty(fileModel.getIdentifier(), username); + Sync_Status status = WorkspaceThreddsSynchronize.getInstance() + .getSynchedStatusFromItemProperty(fileModel.getIdentifier(), username); fileModel.setSyncThreddsStatus(status); } } catch (ItemNotSynched e) { - //silent - logger.trace("Item: "+fileModel.getIdentifier() + " name: "+fileModel.getName() +" is not synched"); + // silent + logger.trace("Item: " + fileModel.getIdentifier() + " name: " + fileModel.getName() + " is not synched"); } catch (Exception e) { - logger.warn("It is not possible to get synched status for item: "+fileModel.getIdentifier()); + logger.warn("It is not possible to get synched status for item: " + fileModel.getIdentifier()); } return fileModel; diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/tostoragehub/StorageHubToWorkpaceConverter.java b/src/main/java/org/gcube/portlets/user/workspace/server/tostoragehub/StorageHubToWorkpaceConverter.java index af10092..13d4121 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/tostoragehub/StorageHubToWorkpaceConverter.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/tostoragehub/StorageHubToWorkpaceConverter.java @@ -247,7 +247,7 @@ public class StorageHubToWorkpaceConverter implements Serializable{ portalLogin = ""; } - return new InfoContactModel(portalLogin, portalLogin, UserUtil.getUserFullName(portalLogin), false); + return new InfoContactModel(portalLogin, portalLogin, UserUtil.getUserFullName(portalLogin), "",false); } /** diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java b/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java index 65f074e..fcd3a5d 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java @@ -225,6 +225,18 @@ public class WsUtil { } + /** + * 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"; + } + /** * Gets the GWT workspace builder. * @@ -244,7 +256,7 @@ public class WsUtil { builder = new GWTWorkspaceBuilder(); // ADDED 03/09/2013 builder.setContexInfo( - new InfoContactModel(info.getUsername(), info.getUsername(), info.getUserFullName(), false), + new InfoContactModel(info.getUsername(), info.getUsername(), info.getUserFullName(), "", false), info.getCurrentScope()); session.setAttribute(WORKSPACEBUILDER_ATTRIBUTE, builder); }