diff --git a/distro/changelog.xml b/distro/changelog.xml index 448d10b..1664c78 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -1,10 +1,12 @@ + date="2016-09-29"> [Feature #2335] Added "Get Folder Link" facility [Incident #4878] Fixed: Workspace tree not displaying user's name Added 'gcube-url-shortener' dependency, removed internal classes for shortener + [Feature #5116] Implemented Show public folders in Workspace via Smart Folder + [Feature #5110] Added Enabled/Disabled Public Access to workspace history diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java b/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java index 8fc3dd9..e2adb07 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java @@ -1740,7 +1740,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt SmartFolderSelectedEvent smartEvent = (SmartFolderSelectedEvent) event; - sub.smartFolderSelected(smartEvent.getIdSmartFolder(), smartEvent.getCategory()); + sub.smartFolderSelected(smartEvent.getSmartFolderCustomId(), smartEvent.getCategory()); }else if(event instanceof FileUploadEvent){ diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsExplorer.java b/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsExplorer.java index 796271e..6a6df3d 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsExplorer.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsExplorer.java @@ -10,8 +10,9 @@ import com.google.gwt.i18n.client.NumberFormat; //import com.google.gwt.user.client.Element; /** - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * The Class ConstantsExplorer. * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it */ public class ConstantsExplorer { @@ -28,7 +29,7 @@ public class ConstantsExplorer { public static final String DOWNLOAD_WORKSPACE_FOLDER_PROTOCOL_ERROR_DURING_COMPRESSION = "ERROR_DURING_COMPRESSION"; public static final String DOWNLOAD_WORKSPACE_FOLDER_PROTOCOL_ERROR_NOT_A_FOLDER = "ERROR_NOT_A_FOLDER"; public static final String DOWNLOAD_WORKSPACE_FOLDER_PROTOCOL_ERROR_SESSION_EXPIRED = "ERROR_SESSION_EXPIRED"; - + public static final String SERVER_ERROR = "Sorry, an error has occurred on the server when"; public static final String TRY_AGAIN = "Try again"; @@ -106,7 +107,13 @@ public class ConstantsExplorer { // public static final String FILE = "File"; // public static final String ARCHIVE = "Archive"; - public static enum WS_UPLOAD_TYPE {File, Archive}; + /** + * The Enum WS_UPLOAD_TYPE. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Sep 29, 2016 + */ +public static enum WS_UPLOAD_TYPE {File, Archive}; public static final String ERROR = "Error"; public static final String NOFILESPECIFIED = "No file specified"; @@ -199,10 +206,23 @@ public class ConstantsExplorer { public static final String GET_SEARCH_PARAMETER ="search"; public static final String GET_ITEMID_PARAMETER ="itemid"; public static final String GET_OPERATION_PARAMETER ="operation"; + + /** + * The Enum WsPortletInitOperation. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Sep 29, 2016 + */ public static enum WsPortletInitOperation {sharelink, gotofolder}; //INIT OPERATIONS //DEFAULT INIT OPERATION public static final WsPortletInitOperation DEFAULT_OPERATION = WsPortletInitOperation.gotofolder; + /** + * The Enum ViewSwitchType. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Sep 29, 2016 + */ public enum ViewSwitchType {Tree, SmartFolder, Messages}; //SERLVET ERROR @@ -225,8 +245,11 @@ public class ConstantsExplorer { public static final int HEIGHT_DIALOG_SHARE_FOLDER = 445; - - + /** + * Log. + * + * @param txt the txt + */ public static native void log(String txt) /*-{ console.log(txt) }-*/; diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/event/SmartFolderSelectedEvent.java b/src/main/java/org/gcube/portlets/user/workspace/client/event/SmartFolderSelectedEvent.java index bedaf28..ea98481 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/event/SmartFolderSelectedEvent.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/event/SmartFolderSelectedEvent.java @@ -1,55 +1,111 @@ package org.gcube.portlets.user.workspace.client.event; import org.gcube.portlets.user.workspace.client.interfaces.EventsTypeEnum; +import org.gcube.portlets.user.workspace.client.interfaces.GXTCategorySmartFolder; import org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface; import com.google.gwt.event.shared.GwtEvent; /** - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * The Class SmartFolderSelectedEvent. * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it */ public class SmartFolderSelectedEvent extends GwtEvent implements GuiEventInterface{ public static Type TYPE = new Type(); - private String idSmartFolder; - private String smartFolderName; - private String category; + private GXTCategorySmartFolder category; - public SmartFolderSelectedEvent(String idSmartFolder, String smartFolderName, String category) { - this.idSmartFolder = idSmartFolder; - this.smartFolderName = smartFolderName; + private String smartFolderCustomId; + + private String smartFolderCustomName; + + private String query; + + /** + * Instantiates a new smart folder selected event. + * + * @param category the category + */ + public SmartFolderSelectedEvent(GXTCategorySmartFolder category) { this.category = category; } + /** + * A custom Smart Folder created by user + * @param identifier + * @param name + * @param object + */ + public SmartFolderSelectedEvent(String identifier, String name, String query) { + this.smartFolderCustomId = identifier; + this.smartFolderCustomName = name; + this.query = query; + } + + + /* (non-Javadoc) + * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() + */ @Override public Type getAssociatedType() { // TODO Auto-generated method stub return TYPE; } + /* (non-Javadoc) + * @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler) + */ @Override protected void dispatch(SmartFolderSelectedEventHandler handler) { handler.onSmartFolderSelected(this); - + } + /* (non-Javadoc) + * @see org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface#getKey() + */ @Override public EventsTypeEnum getKey() { // TODO Auto-generated method stub return EventsTypeEnum.SMART_FOLDER_EVENT; } - public String getIdSmartFolder() { - return idSmartFolder; - } - public String getSmartFolderName() { - return smartFolderName; - } - - public String getCategory() { + /** + * Gets the category. + * + * @return the category + */ + public GXTCategorySmartFolder getCategory() { return category; } - + + + /** + * @return the smartFolderCustomId + */ + public String getSmartFolderCustomId() { + + return smartFolderCustomId; + } + + + /** + * @return the smartFolderCustomName + */ + public String getSmartFolderCustomName() { + + return smartFolderCustomName; + } + + /** + * @return the query + */ + public String getQuery() { + + return query; + } + + } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/interfaces/GXTCategoryItemInterface.java b/src/main/java/org/gcube/portlets/user/workspace/client/interfaces/GXTCategoryItemInterface.java deleted file mode 100644 index 80c37af..0000000 --- a/src/main/java/org/gcube/portlets/user/workspace/client/interfaces/GXTCategoryItemInterface.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.gcube.portlets.user.workspace.client.interfaces; -import java.io.Serializable; - - -/** - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it - * - */ -public class GXTCategoryItemInterface implements Serializable { - - - private static final long serialVersionUID = -9099563454980400252L; - - //Smart Folder SMF - //VALUE = KEY - THE KEY TO SEARCH BY CATEORY IN HOME LIBRARY - public static final String SMF_BIODIVERSITY = "Biodiversity"; - public static final String SMF_DOCUMENTS = "Documents"; - public static final String SMF_IMAGES = "Images"; - public static final String SMF_REPORTS = "Reports"; - public static final String SMF_TIMESERIES = "Time Series"; - public static final String SMF_LINKS = "Links"; - public static final String SMF_UNKNOWN = "Unknown"; - public static final String SMF_FOLDERS = "Folders"; - public static final String SMF_SHARED_FOLDERS = "Shared Folders"; - public static final String SMF_GCUBE_ITEMS= "Gcube Items"; -// public static final String SMF_VRE_FOLDERS = "VRE Folders"; - - public GXTCategoryItemInterface(){} - - //Messages MS - public static final String MS_MESSAGES = "Messages"; - public static final String MS_SENT = "Sent"; - public static final String MS_RECEIVED = "Received"; - - -} diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/interfaces/GXTCategorySmartFolder.java b/src/main/java/org/gcube/portlets/user/workspace/client/interfaces/GXTCategorySmartFolder.java new file mode 100644 index 0000000..d39eb40 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/workspace/client/interfaces/GXTCategorySmartFolder.java @@ -0,0 +1,51 @@ +package org.gcube.portlets.user.workspace.client.interfaces; + + +/** + * The Enum GXTCategoryItemInterface. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Sep 29, 2016 + */ +public enum GXTCategorySmartFolder { + + //Smart Folder for Folder ITEM + //VALUE = KEY - THE KEY TO SEARCH BY CATEORY IN HOME LIBRARY +// public static final String SMF_VRE_FOLDERS = "VRE Folders"; + SMF_BIODIVERSITY("Biodiversity", "Biodiversity"), + SMF_DOCUMENTS("Documents","Documents"), + SMF_IMAGES("Images","Images"), + SMF_REPORTS("Reports", "Reports"), + SMF_TIMESERIES("Time Series","Time Series"), + SMF_LINKS("Links","Links"), + SMF_FOLDERS("Folder","Folder"), + SMF_SHARED_FOLDERS("Shared_Folders", "Shared Folders"), + SMF_GCUBE_ITEMS("Gcube_Items","Gcube Items"), + SMF_PUBLIC_FOLDERS("Public_Folders", "Public Folders"), + SMF_UNKNOWN("Unknown", "Unknown"); + + private String id; + private String value; + + GXTCategorySmartFolder(String id, String value){ + this.id = id; + this.value = value; + } + + /** + * @return the id + */ + public String getId() { + + return id; + } + + + /** + * @return the value + */ + public String getValue() { + + return value; + } +} diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/interfaces/SubscriberInterface.java b/src/main/java/org/gcube/portlets/user/workspace/client/interfaces/SubscriberInterface.java index 9967238..4571c37 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/interfaces/SubscriberInterface.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/interfaces/SubscriberInterface.java @@ -19,7 +19,7 @@ import org.gcube.portlets.user.workspace.shared.WorkspaceTrashOperation; * Oct 6, 2015 */ public interface SubscriberInterface { - + /** * Added file. @@ -67,7 +67,7 @@ public interface SubscriberInterface { /** * Delete items. * - * @param itemsIdentifier the items identifier + * @param ids the ids * @return true, if successful */ boolean deleteItems(List ids); @@ -87,13 +87,14 @@ public interface SubscriberInterface { */ void rootLoaded(FileModel root); + /** * Smart folder selected. * * @param folderId the folder id - * @param category the category + * @param gxtCategorySmartFolder the gxt category smart folder */ - void smartFolderSelected(String folderId, String category); + void smartFolderSelected(String folderId, GXTCategorySmartFolder gxtCategorySmartFolder); /** * Moved items. diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/model/FileModel.java b/src/main/java/org/gcube/portlets/user/workspace/client/model/FileModel.java index eaf1005..342a914 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/model/FileModel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/model/FileModel.java @@ -4,6 +4,7 @@ import java.io.Serializable; import java.util.List; import org.gcube.portlets.user.workspace.client.ConstantsExplorer; +import org.gcube.portlets.user.workspace.client.interfaces.GXTCategorySmartFolder; import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum; import org.gcube.portlets.user.workspace.client.resources.Resources; @@ -28,6 +29,7 @@ public class FileModel extends BaseModelData implements Serializable { private static final long serialVersionUID = 1L; protected GXTFolderItemTypeEnum folderItemType; //It's here to serialization don't remove + protected GXTCategorySmartFolder smartFolders; //It's here to serialization don't remove protected InfoContactModel infoContacts; protected boolean isRoot = false; protected boolean isVreFolder; @@ -92,7 +94,7 @@ public class FileModel extends BaseModelData implements Serializable { * Inits the default properties. */ private void initDefaultProperties(){ - setShortcutCategory(""); + setShortcutCategory(GXTCategorySmartFolder.SMF_UNKNOWN); setShareable(true); } @@ -369,10 +371,10 @@ public class FileModel extends BaseModelData implements Serializable { /** * Sets the shortcut category. * - * @param category the new shortcut category + * @param smfDocuments the new shortcut category */ - public void setShortcutCategory(String category) { - set(SHORTCUTCATEGORY, category); + public void setShortcutCategory(GXTCategorySmartFolder smfDocuments) { + set(SHORTCUTCATEGORY, smfDocuments); } /** diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/model/SmartFolderModel.java b/src/main/java/org/gcube/portlets/user/workspace/client/model/SmartFolderModel.java index a0fc7d1..c5dbca4 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/model/SmartFolderModel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/model/SmartFolderModel.java @@ -4,9 +4,12 @@ import java.io.Serializable; import com.extjs.gxt.ui.client.data.BaseModelData; + /** - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * The Class SmartFolderModel. * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Sep 29, 2016 */ public class SmartFolderModel extends BaseModelData implements Serializable { @@ -16,10 +19,20 @@ public class SmartFolderModel extends BaseModelData implements Serializable { private static final long serialVersionUID = 1L; - SmartFolderModel(){ + /** + * Instantiates a new smart folder model. + */ + public SmartFolderModel(){ } + /** + * Instantiates a new smart folder model. + * + * @param id the id + * @param name the name + * @param query the query + */ public SmartFolderModel(String id, String name, String query){ setIdentifier(id); setName(name); @@ -27,26 +40,56 @@ public class SmartFolderModel extends BaseModelData implements Serializable { } + /** + * Sets the identifier. + * + * @param id the new identifier + */ public void setIdentifier(String id) { set(FileModel.IDENTIFIER,id); } + /** + * Sets the name. + * + * @param name the new name + */ private void setName(String name){ set(FileModel.NAME, name); } + /** + * Sets the query. + * + * @param query the new query + */ private void setQuery(String query){ set(FileModel.QUERY, query); } + /** + * Gets the identifier. + * + * @return the identifier + */ public String getIdentifier() { return get(FileModel.IDENTIFIER); } + /** + * Gets the name. + * + * @return the name + */ public String getName(){ return get(FileModel.NAME); } + /** + * Gets the query. + * + * @return the query + */ public String getQuery(){ return get(FileModel.QUERY); } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java index 5cf6d60..e54d664 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java @@ -5,6 +5,7 @@ import java.util.Date; import java.util.List; import java.util.Map; +import org.gcube.portlets.user.workspace.client.interfaces.GXTCategorySmartFolder; import org.gcube.portlets.user.workspace.client.model.FileDetailsModel; import org.gcube.portlets.user.workspace.client.model.FileGridModel; import org.gcube.portlets.user.workspace.client.model.FileModel; @@ -40,6 +41,13 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; */ @RemoteServiceRelativePath("WorkspaceService") public interface GWTWorkspaceService extends RemoteService{ + + /** + * Gets the servlet context path. + * + * @param protocol the protocol + * @return the servlet context path + */ String getServletContextPath(String protocol); /** * Gets the user workspace size. @@ -128,9 +136,10 @@ public interface GWTWorkspaceService extends RemoteService{ * * @param category the category * @return the smart folder results by category - * @throws Exception the exception + * @throws Exception */ - public List getSmartFolderResultsByCategory(String category) throws Exception; + List getSmartFolderResultsByCategory( + GXTCategorySmartFolder category) throws Exception; /** * Creates the smart folder. @@ -528,7 +537,8 @@ public interface GWTWorkspaceService extends RemoteService{ /** * Gets the my login. - * @param the current url of the portlet + * + * @param currentPortletUrl the current portlet url * @return the my login */ UserBean getMyLogin(String currentPortletUrl); @@ -692,12 +702,30 @@ public interface GWTWorkspaceService extends RemoteService{ */ void setGcubeItemProperties(String itemId, Map properties) throws Exception; + /** + * Gets the item for file tree. + * + * @param itemId the item id + * @return the item for file tree + * @throws Exception the exception + */ FileModel getItemForFileTree(String itemId) throws Exception; /** - * @return + * Gets the my first name. + * + * @return the my first name */ String getMyFirstName(); + /** + * Mark folder as public for folder item id. + * + * @param itemId the item id + * @param b the b + * @return the public link + * @throws SessionExpiredException the session expired exception + * @throws Exception the exception + */ PublicLink markFolderAsPublicForFolderItemId(String itemId, boolean b) throws SessionExpiredException, Exception; } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java index 49e69e2..b2d1e29 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java @@ -5,6 +5,7 @@ import java.util.Date; import java.util.List; import java.util.Map; +import org.gcube.portlets.user.workspace.client.interfaces.GXTCategorySmartFolder; import org.gcube.portlets.user.workspace.client.model.FileDetailsModel; import org.gcube.portlets.user.workspace.client.model.FileGridModel; import org.gcube.portlets.user.workspace.client.model.FileModel; @@ -146,6 +147,7 @@ public interface GWTWorkspaceServiceAsync { */ void getItemsBySearchName(String text, String folderId, AsyncCallback> callback); + /** * Gets the smart folder results by category. * @@ -153,7 +155,7 @@ public interface GWTWorkspaceServiceAsync { * @param callback the callback * @return the smart folder results by category */ - void getSmartFolderResultsByCategory(String category, AsyncCallback> callback); + void getSmartFolderResultsByCategory(GXTCategorySmartFolder category, AsyncCallback> callback); /** * Creates the smart folder. @@ -525,7 +527,8 @@ public interface GWTWorkspaceServiceAsync { /** * Gets the my login. - * @param the current url of the portlet + * + * @param currentPortletUrl the current portlet url * @param callback the callback * @return the my login */ @@ -712,6 +715,13 @@ public interface GWTWorkspaceServiceAsync { void markFolderAsPublicForFolderItemId( String itemId, boolean setPublic, AsyncCallback callback); + /** + * Gets the servlet context path. + * + * @param protocol the protocol + * @param callback the callback + * @return the servlet context path + */ void getServletContextPath(String protocol, AsyncCallback callback); } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/ExplorerPanel.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/ExplorerPanel.java index d2bd789..7f92470 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/ExplorerPanel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/ExplorerPanel.java @@ -184,7 +184,7 @@ public class ExplorerPanel extends LayoutContainer { private void initToolBar(){ toolBar.add(radioGroup); - toolBar.add(buttBulk); +// toolBar.add(buttBulk); } private void switchView(ViewSwitchType type) { diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/smartfolder/SmartFolderPanel.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/smartfolder/SmartFolderPanel.java index ae1fc9a..dd1b590 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/smartfolder/SmartFolderPanel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/smartfolder/SmartFolderPanel.java @@ -1,45 +1,41 @@ package org.gcube.portlets.user.workspace.client.view.smartfolder; -import java.util.HashMap; import java.util.List; import org.gcube.portlets.user.workspace.client.AppControllerExplorer; import org.gcube.portlets.user.workspace.client.ConstantsExplorer; import org.gcube.portlets.user.workspace.client.event.SmartFolderSelectedEvent; -import org.gcube.portlets.user.workspace.client.interfaces.GXTCategoryItemInterface; +import org.gcube.portlets.user.workspace.client.interfaces.GXTCategorySmartFolder; import org.gcube.portlets.user.workspace.client.model.SmartFolderModel; import org.gcube.portlets.user.workspace.client.resources.Resources; import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxAlert; import com.extjs.gxt.ui.client.Style.Scroll; import com.extjs.gxt.ui.client.widget.ContentPanel; -import com.extjs.gxt.ui.client.widget.HorizontalPanel; import com.extjs.gxt.ui.client.widget.LayoutContainer; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.rpc.AsyncCallback; /** + * The Class SmartFolderPanel. + * * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Massimiliano Assante ISTI-CNR - * * @version 1.0 May 14th 2012 */ public class SmartFolderPanel extends LayoutContainer { private ContentPanel cp; + private SmartButton buttDocuments = new SmartButton(GXTCategorySmartFolder.SMF_DOCUMENTS.getValue(), Resources.getIconDocuments(), this); + private SmartButton buttImages = new SmartButton(GXTCategorySmartFolder.SMF_IMAGES.getValue(), Resources.getIconImages(), this); + private SmartButton buttLinks = new SmartButton(GXTCategorySmartFolder.SMF_LINKS.getValue(), Resources.getIconLinks(), this); + private SmartButton buttPublicFolder = new SmartButton(GXTCategorySmartFolder.SMF_PUBLIC_FOLDERS.getValue(), Resources.getIconFolderPublic(), this); - private SmartButton buttDocuments = new SmartButton(GXTCategoryItemInterface.SMF_DOCUMENTS, Resources.getIconDocuments(), this); - - private SmartButton buttImages = new SmartButton(GXTCategoryItemInterface.SMF_IMAGES, Resources.getIconImages(), this); - private SmartButton buttLinks = new SmartButton(GXTCategoryItemInterface.SMF_LINKS, Resources.getIconLinks(), this); -// private SmartButton buttReports = new SmartButton(GXTCategoryItemInterface.SMF_REPORTS, Resources.getIconReport(), this); -// private SmartButton buttTimeSeries = new SmartButton(GXTCategoryItemInterface.SMF_TIMESERIES, Resources.getIconTimeSeries(), this); - - private HashMap hashSmartFolderModel = new HashMap(); - private HashMap hashMapPanelSmartFolder = new HashMap(); - + /** + * Instantiates a new smart folder panel. + */ public SmartFolderPanel() { this.cp = new ContentPanel(); cp.setBodyBorder(false); @@ -49,28 +45,34 @@ public class SmartFolderPanel extends LayoutContainer { add(cp); } + /** + * Reload panel smart folder. + */ public void reloadPanelSmartFolder(){ cp.removeAll(); - cp.add(buttDocuments); - cp.add(buttImages); cp.add(buttLinks); -// cp.add(buttReports); -// cp.add(buttTimeSeries); + cp.add(buttPublicFolder); cp.layout(); addUserSmartFolder(); } - public void deselectAll(){ - for (int i = 0; i < cp.getItemCount(); i++ ) + /** + * Deselect all. + */ + public void deselectAll(){ + for (int i = 0; i < cp.getItemCount(); i++ ) if (cp.getItem(i) instanceof SmartButton) { - SmartButton b = (SmartButton) cp.getItem(i); + SmartButton b = (SmartButton) cp.getItem(i); b.toggle(false); } } + /** + * Adds the user smart folder. + */ private void addUserSmartFolder() { AppControllerExplorer.rpcWorkspaceService.getAllSmartFolders(new AsyncCallback>() { @Override @@ -86,12 +88,15 @@ public class SmartFolderPanel extends LayoutContainer { } + /** + * Adds the listeners. + */ private void addListeners() { buttImages.setCommand(new Command() { @Override public void execute() { - AppControllerExplorer.getEventBus().fireEvent(new SmartFolderSelectedEvent(null, GXTCategoryItemInterface.SMF_IMAGES, GXTCategoryItemInterface.SMF_IMAGES)); + AppControllerExplorer.getEventBus().fireEvent(new SmartFolderSelectedEvent(GXTCategorySmartFolder.SMF_IMAGES)); } }); @@ -99,36 +104,32 @@ public class SmartFolderPanel extends LayoutContainer { buttLinks.setCommand(new Command() { @Override public void execute() { - AppControllerExplorer.getEventBus().fireEvent(new SmartFolderSelectedEvent(null, GXTCategoryItemInterface.SMF_LINKS, GXTCategoryItemInterface.SMF_LINKS)); - } + AppControllerExplorer.getEventBus().fireEvent(new SmartFolderSelectedEvent(GXTCategorySmartFolder.SMF_LINKS)); + } }); buttDocuments.setCommand(new Command() { @Override public void execute() { - AppControllerExplorer.getEventBus().fireEvent(new SmartFolderSelectedEvent(null, GXTCategoryItemInterface.SMF_DOCUMENTS, GXTCategoryItemInterface.SMF_DOCUMENTS)); + AppControllerExplorer.getEventBus().fireEvent(new SmartFolderSelectedEvent(GXTCategorySmartFolder.SMF_DOCUMENTS)); } }); -// buttReports.setCommand(new Command() { -// @Override -// public void execute() { -// AppControllerExplorer.getEventBus().fireEvent(new SmartFolderSelectedEvent(null, GXTCategoryItemInterface.SMF_REPORTS, GXTCategoryItemInterface.SMF_REPORTS)); -// } -// }); -// -// buttTimeSeries.setCommand(new Command() { -// @Override -// public void execute() { -// AppControllerExplorer.getEventBus().fireEvent(new SmartFolderSelectedEvent(null, GXTCategoryItemInterface.SMF_TIMESERIES, GXTCategoryItemInterface.SMF_TIMESERIES)); -// } -// }); + buttPublicFolder.setCommand(new Command() { + + @Override + public void execute() { + + AppControllerExplorer.getEventBus().fireEvent(new SmartFolderSelectedEvent(GXTCategorySmartFolder.SMF_PUBLIC_FOLDERS)); + } + }); } /** - * - * @param result + * Load smart folders. + * + * @param result the result */ public void loadSmartFolders(List result) { if (result != null && result.size() > 0) { @@ -139,6 +140,12 @@ public class SmartFolderPanel extends LayoutContainer { } } + + /** + * Load smart folder. + * + * @param smart the smart + */ public void loadSmartFolder(final SmartFolderModel smart) { SmartButton userSmartFolder = new SmartButton(smart.getName(), Resources.getIconStar(), this, true); @@ -153,23 +160,42 @@ public class SmartFolderPanel extends LayoutContainer { cp.layout(); } + /** + * Sets the size smart panel. + * + * @param width the width + * @param height the height + */ public void setSizeSmartPanel(int width, int height) { - cp.setSize(width, height); + cp.setSize(width, height); } - public void removeSmartFolder(String smartIdentifier) { + /** + * Removes the smart folder. + * + * @param smartIdentifier the smart identifier + */ + public void removeSmartFolder(String smartIdentifier) { cp.remove(cp.getItemByItemId(smartIdentifier)); cp.layout(true); } + /** + * Un pressed all toogle. + */ public void unPressedAllToogle(){ deselectAll(); } - public void toggleOthers(SmartButton button){ - for (int i = 0; i < cp.getItemCount(); i++ ) + /** + * Toggle others. + * + * @param button the button + */ + public void toggleOthers(SmartButton button){ + for (int i = 0; i < cp.getItemCount(); i++ ) if (cp.getItem(i) instanceof SmartButton) { - SmartButton b = (SmartButton) cp.getItem(i); + SmartButton b = (SmartButton) cp.getItem(i); if (! b.equals(button)) b.toggle(false); } 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 336c24d..abaff54 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 @@ -53,7 +53,7 @@ import org.gcube.common.homelibrary.home.workspace.trash.WorkspaceTrashFolder; import org.gcube.common.homelibrary.home.workspace.trash.WorkspaceTrashItem; import org.gcube.common.homelibrary.home.workspace.usermanager.GCubeGroup; import org.gcube.portlets.user.workspace.client.ConstantsExplorer; -import org.gcube.portlets.user.workspace.client.interfaces.GXTCategoryItemInterface; +import org.gcube.portlets.user.workspace.client.interfaces.GXTCategorySmartFolder; import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum; import org.gcube.portlets.user.workspace.client.model.FileDetailsModel; import org.gcube.portlets.user.workspace.client.model.FileGridModel; @@ -765,7 +765,7 @@ public class GWTWorkspaceBuilder { case FOLDER: fileGridModel = new FolderGridModel(item.getId(), item.getName(), toDate(item.getLastModified()), parentFileModel, -1, true, false,false, false); fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER.getLabel()); - fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_FOLDERS); + fileGridModel.setShortcutCategory(GXTCategorySmartFolder.SMF_FOLDERS); fileGridModel.setShareable(true); break; @@ -779,7 +779,7 @@ public class GWTWorkspaceBuilder { //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(GXTCategoryItemInterface.SMF_SHARED_FOLDERS); + fileGridModel.setShortcutCategory(GXTCategorySmartFolder.SMF_SHARED_FOLDERS); fileGridModel.setShareable(true); break; @@ -861,7 +861,7 @@ public class GWTWorkspaceBuilder { else fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER.getLabel().toString()); - fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_FOLDERS); + fileGridModel.setShortcutCategory(GXTCategorySmartFolder.SMF_FOLDERS); fileGridModel.setShareable(true); fileGridModel.setDescription(item.getDescription()); break; @@ -883,7 +883,7 @@ public class GWTWorkspaceBuilder { else fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER_SHARED.getLabel().toString()); - fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_SHARED_FOLDERS); + fileGridModel.setShortcutCategory(GXTCategorySmartFolder.SMF_SHARED_FOLDERS); fileGridModel.setShareable(true); fileGridModel.setDescription(item.getDescription()); break; @@ -938,68 +938,68 @@ public class GWTWorkspaceBuilder { { case EXTERNAL_IMAGE: fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_IMAGE); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_IMAGES); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_IMAGES); fileModel.setType(searchFolderItem.getMimeType()); break; case EXTERNAL_FILE: fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_FILE); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_DOCUMENTS); fileModel.setType(searchFolderItem.getMimeType()); break; case EXTERNAL_PDF_FILE: fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_PDF_FILE); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_DOCUMENTS); fileModel.setType(searchFolderItem.getMimeType()); break; case EXTERNAL_URL: fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_URL); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_LINKS); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_LINKS); break; case REPORT_TEMPLATE: fileModel.setFolderItemType(GXTFolderItemTypeEnum.REPORT_TEMPLATE); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_REPORTS); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_REPORTS); break; case REPORT: fileModel.setFolderItemType(GXTFolderItemTypeEnum.REPORT); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_REPORTS); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_REPORTS); break; case QUERY: fileModel.setFolderItemType(GXTFolderItemTypeEnum.QUERY); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_DOCUMENTS); break; case TIME_SERIES: fileModel.setFolderItemType(GXTFolderItemTypeEnum.TIME_SERIES); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_TIMESERIES); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_TIMESERIES); break; case PDF_DOCUMENT: fileModel.setFolderItemType(GXTFolderItemTypeEnum.PDF_DOCUMENT); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_DOCUMENTS); break; case IMAGE_DOCUMENT: fileModel.setFolderItemType(GXTFolderItemTypeEnum.IMAGE_DOCUMENT); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_IMAGES); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_IMAGES); fileModel.setType(searchFolderItem.getMimeType()); break; case DOCUMENT: fileModel.setFolderItemType(GXTFolderItemTypeEnum.DOCUMENT); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_DOCUMENTS); fileModel.setType(searchFolderItem.getMimeType()); break; case URL_DOCUMENT: fileModel.setFolderItemType(GXTFolderItemTypeEnum.URL_DOCUMENT); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_DOCUMENTS); break; case METADATA: fileModel.setFolderItemType(GXTFolderItemTypeEnum.METADATA); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_DOCUMENTS); break; case GCUBE_ITEM: fileModel.setFolderItemType(GXTFolderItemTypeEnum.GCUBE_ITEM); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_GCUBE_ITEMS); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_GCUBE_ITEMS); break; default: fileModel.setFolderItemType(GXTFolderItemTypeEnum.UNKNOWN_TYPE); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_UNKNOWN); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_UNKNOWN); fileModel.setType(GXTFolderItemTypeEnum.UNKNOWN_TYPE.toString()); break; } @@ -1020,49 +1020,49 @@ public class GWTWorkspaceBuilder { { case EXTERNAL_IMAGE: fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_IMAGE); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_IMAGES); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_IMAGES); ExternalImage extImage = (ExternalImage) worspaceFolderItem; fileModel.setType(extImage.getMimeType()); break; case EXTERNAL_FILE: fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_FILE); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_DOCUMENTS); ExternalFile extFile = (ExternalFile) worspaceFolderItem; fileModel.setType(extFile.getMimeType()); break; case EXTERNAL_PDF_FILE: fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_PDF_FILE); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_DOCUMENTS); ExternalPDFFile pdfExt = (ExternalPDFFile) worspaceFolderItem; fileModel.setType(pdfExt.getMimeType()); break; case EXTERNAL_URL: fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_URL); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_LINKS); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_LINKS); break; case REPORT_TEMPLATE: fileModel.setFolderItemType(GXTFolderItemTypeEnum.REPORT_TEMPLATE); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_REPORTS); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_REPORTS); break; case REPORT: fileModel.setFolderItemType(GXTFolderItemTypeEnum.REPORT); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_REPORTS); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_REPORTS); break; case QUERY: fileModel.setFolderItemType(GXTFolderItemTypeEnum.QUERY); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_DOCUMENTS); break; case TIME_SERIES: fileModel.setFolderItemType(GXTFolderItemTypeEnum.TIME_SERIES); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_TIMESERIES); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_TIMESERIES); break; case PDF_DOCUMENT: fileModel.setFolderItemType(GXTFolderItemTypeEnum.PDF_DOCUMENT); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_DOCUMENTS); break; case IMAGE_DOCUMENT: fileModel.setFolderItemType(GXTFolderItemTypeEnum.IMAGE_DOCUMENT); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_IMAGES); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_IMAGES); // ImageDocument imgDoc = (ImageDocument) worspaceFolderItem; GCubeItem imgDoc = (GCubeItem) worspaceFolderItem; //Cast GCubeItem try { @@ -1073,7 +1073,7 @@ public class GWTWorkspaceBuilder { break; case DOCUMENT: fileModel.setFolderItemType(GXTFolderItemTypeEnum.DOCUMENT); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_DOCUMENTS); // Document doc = (Document) worspaceFolderItem; GCubeItem doc = (GCubeItem) worspaceFolderItem; //Cast GCubeItem try { @@ -1084,19 +1084,19 @@ public class GWTWorkspaceBuilder { break; case URL_DOCUMENT: fileModel.setFolderItemType(GXTFolderItemTypeEnum.URL_DOCUMENT); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_DOCUMENTS); break; case METADATA: fileModel.setFolderItemType(GXTFolderItemTypeEnum.METADATA); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_DOCUMENTS); break; case GCUBE_ITEM: fileModel.setFolderItemType(GXTFolderItemTypeEnum.GCUBE_ITEM); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_GCUBE_ITEMS); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_GCUBE_ITEMS); break; default: fileModel.setFolderItemType(GXTFolderItemTypeEnum.UNKNOWN_TYPE); - fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_UNKNOWN); + fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_UNKNOWN); fileModel.setType(GXTFolderItemTypeEnum.UNKNOWN_TYPE.toString()); break; } @@ -1339,13 +1339,13 @@ public class GWTWorkspaceBuilder { * @return the folder item type category * @throws InternalErrorException the internal error exception */ - protected String getFolderItemTypeCategory(SearchItem item) throws InternalErrorException{ + protected GXTCategorySmartFolder getFolderItemTypeCategory(SearchItem item) throws InternalErrorException{ switch (item.getType()) { case FOLDER: - return GXTCategoryItemInterface.SMF_DOCUMENTS; + return GXTCategorySmartFolder.SMF_DOCUMENTS; case FOLDER_ITEM: @@ -1353,40 +1353,40 @@ public class GWTWorkspaceBuilder { switch(folderItem.getFolderItemType()) { case EXTERNAL_IMAGE: - return GXTCategoryItemInterface.SMF_IMAGES; + return GXTCategorySmartFolder.SMF_IMAGES; case EXTERNAL_FILE: - return GXTCategoryItemInterface.SMF_DOCUMENTS; + return GXTCategorySmartFolder.SMF_DOCUMENTS; case EXTERNAL_PDF_FILE: - return GXTCategoryItemInterface.SMF_DOCUMENTS; + return GXTCategorySmartFolder.SMF_DOCUMENTS; case EXTERNAL_URL: - return GXTCategoryItemInterface.SMF_LINKS; + return GXTCategorySmartFolder.SMF_LINKS; case REPORT_TEMPLATE: - return GXTCategoryItemInterface.SMF_REPORTS; + return GXTCategorySmartFolder.SMF_REPORTS; case REPORT: - return GXTCategoryItemInterface.SMF_REPORTS; + return GXTCategorySmartFolder.SMF_REPORTS; case QUERY: - return GXTCategoryItemInterface.SMF_DOCUMENTS; + return GXTCategorySmartFolder.SMF_DOCUMENTS; case TIME_SERIES: - return GXTCategoryItemInterface.SMF_TIMESERIES; + return GXTCategorySmartFolder.SMF_TIMESERIES; case PDF_DOCUMENT: - return GXTCategoryItemInterface.SMF_DOCUMENTS; + return GXTCategorySmartFolder.SMF_DOCUMENTS; case IMAGE_DOCUMENT: - return GXTCategoryItemInterface.SMF_IMAGES; + return GXTCategorySmartFolder.SMF_IMAGES; case DOCUMENT: - return GXTCategoryItemInterface.SMF_DOCUMENTS; + return GXTCategorySmartFolder.SMF_DOCUMENTS; case URL_DOCUMENT: - return GXTCategoryItemInterface.SMF_DOCUMENTS; + return GXTCategorySmartFolder.SMF_DOCUMENTS; case METADATA: - return GXTCategoryItemInterface.SMF_DOCUMENTS; + return GXTCategorySmartFolder.SMF_DOCUMENTS; case GCUBE_ITEM: - return GXTCategoryItemInterface.SMF_GCUBE_ITEMS; + return GXTCategorySmartFolder.SMF_GCUBE_ITEMS; default: - return GXTCategoryItemInterface.SMF_UNKNOWN; + return GXTCategorySmartFolder.SMF_UNKNOWN; } default: logger.error("gxt conversion return null for item "+item.getName()); - return GXTCategoryItemInterface.SMF_UNKNOWN; + return GXTCategorySmartFolder.SMF_UNKNOWN; } } @@ -1399,7 +1399,7 @@ public class GWTWorkspaceBuilder { * @return the list * @throws Exception the exception */ - public List filterListFileGridModelItemByCategory(List listSearchItem, String 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()); @@ -1683,7 +1683,7 @@ public class GWTWorkspaceBuilder { List listAccFields = new ArrayList(); if(accoutings!=null){ - logger.trace("accoutings size "+accoutings.size()+ "converting"); + logger.trace("accoutings size "+accoutings.size()+ ", converting..."); for (AccountingEntry accountingEntry : accoutings) { @@ -1890,7 +1890,7 @@ public class GWTWorkspaceBuilder { listAccFields.add(af); } } - logger.trace("get accounting readers converting completed - returning size "+listAccFields.size()); + logger.debug("get accounting readers converting completed - returning size "+listAccFields.size()); return listAccFields; diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java index 2f537ac..b82c651 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java @@ -50,7 +50,7 @@ import org.gcube.datacatalogue.ckanutillibrary.utils.SessionCatalogueAttributes; import org.gcube.datacatalogue.ckanutillibrary.utils.UtilMethods; import org.gcube.portlets.user.urlshortener.UrlShortener; import org.gcube.portlets.user.workspace.client.ConstantsExplorer; -import org.gcube.portlets.user.workspace.client.interfaces.GXTCategoryItemInterface; +import org.gcube.portlets.user.workspace.client.interfaces.GXTCategorySmartFolder; import org.gcube.portlets.user.workspace.client.model.FileDetailsModel; import org.gcube.portlets.user.workspace.client.model.FileGridModel; import org.gcube.portlets.user.workspace.client.model.FileModel; @@ -1076,7 +1076,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT * @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getSmartFolderResultsByCategory(java.lang.String) */ @Override - public List getSmartFolderResultsByCategory(String category) throws Exception { + public List getSmartFolderResultsByCategory(GXTCategorySmartFolder category) throws Exception { try { @@ -1086,13 +1086,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT List listWorkspaceItems = new ArrayList(); //Category IMAGES - if(category.equals(GXTCategoryItemInterface.SMF_IMAGES.toString())){ + if(category.equals(GXTCategorySmartFolder.SMF_IMAGES)){ listWorkspaceItems = workspace.getFolderItems(FolderItemType.IMAGE_DOCUMENT, FolderItemType.EXTERNAL_IMAGE); //Category BIODIVERSITY - }else if(category.equals(GXTCategoryItemInterface.SMF_BIODIVERSITY.toString())){ + }else if(category.equals(GXTCategorySmartFolder.SMF_BIODIVERSITY)){ // listWorkspaceItems = workspace.getFolderItems(FolderItemType.AQUAMAPS_ITEM); //Category DOCUMENTS - }else if(category.equals(GXTCategoryItemInterface.SMF_DOCUMENTS.toString())){ + }else if(category.equals(GXTCategorySmartFolder.SMF_DOCUMENTS)){ listWorkspaceItems = workspace.getFolderItems( FolderItemType.EXTERNAL_FILE, @@ -1104,16 +1104,21 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT ); //Category LINKS - }else if(category.equals(GXTCategoryItemInterface.SMF_LINKS.toString())){ + }else if(category.equals(GXTCategorySmartFolder.SMF_LINKS)){ // listWorkspaceItems = workspace.getFolderItems(FolderItemType.EXTERNAL_URL, FolderItemType.URL_DOCUMENT, FolderItemType.EXTERNAL_RESOURCE_LINK); //Category REPORTS - }else if(category.equals(GXTCategoryItemInterface.SMF_REPORTS.toString())){ + }else if(category.equals(GXTCategorySmartFolder.SMF_REPORTS)){ listWorkspaceItems = workspace.getFolderItems(FolderItemType.REPORT_TEMPLATE, FolderItemType.REPORT); //Category TIME SERIES - }else if(category.equals(GXTCategoryItemInterface.SMF_TIMESERIES.toString())){ + }else if(category.equals(GXTCategorySmartFolder.SMF_TIMESERIES)){ listWorkspaceItems = workspace.getFolderItems(FolderItemType.TIME_SERIES); } - else + else if(category.equals(GXTCategorySmartFolder.SMF_PUBLIC_FOLDERS)){ + List listFolder = workspace.getPublicFolders(); + if(listFolder==null || listFolder.isEmpty()) + return new ArrayList(); + return builder.buildGXTListFileGridModelItem(listFolder, null); + }else new Exception("Smart folder category unknown"); return builder.filterListFileGridModelItemByCategory(listWorkspaceItems, category); @@ -1481,7 +1486,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT workspaceLogger.debug("Get all contacts from server..."); GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder(); - + getWorkspace(); //DO NOT REMOVE, IT IS NEEDED TO SET TOKEN IN ECLIPSE org.gcube.common.homelibrary.home.workspace.usermanager.UserManager hlUserManager = HomeLibrary.getHomeManagerFactory().getUserManager(); if(isTestMode()){ @@ -3594,7 +3599,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT @Override public String getServletContextPath(String protocol) { HttpServletRequest req = getThreadLocalRequest(); - + String scheme = protocol; String serverName = req.getServerName(); // hostname.com 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 2800d30..c395bbb 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 @@ -56,6 +56,7 @@ public class WsUtil { public static final String NOTIFICATION_PORTLET_CLASS_ID = "org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl"; //IN DEV public static final String TEST_SCOPE = "/gcube"; + public static final String TEST_TOKEN = "89257623-0570-4fbe-a15b-458bb84f4902-98187548"; //username Francesco Mangiacrapa scope: NextNext // public static final String TEST_USER = "pasquale.pagano"; // public static final String TEST_USER = "federico.defaveri"; @@ -114,6 +115,7 @@ public class WsUtil { if (!isWithinPortal()) { //DEV MODE user = "francesco.mangiacrapa"; TEST_USER_FULL_NAME = "Francesco Mangiacrapa"; + //SecurityTokenProvider.instance.set(TEST_TOKEN); } logger.warn("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND - PORTLETS STARTING WITH FOLLOWING SETTINGS:"); @@ -123,7 +125,7 @@ public class WsUtil { logger.warn("USERNAME_ATTRIBUTE: "+USERNAME_ATTRIBUTE); session = SessionManager.getInstance().getASLSession(sessionID, user); session.setScope(TEST_SCOPE); - + session.setSecurityToken(TEST_TOKEN); //MANDATORY FOR SOCIAL LIBRARY session.setUserAvatarId(user + "Avatar"); diff --git a/src/test/java/org/gcube/portlets/user/workspace/SmartFolderTest.java b/src/test/java/org/gcube/portlets/user/workspace/SmartFolderTest.java index 4a599d7..8a4f505 100644 --- a/src/test/java/org/gcube/portlets/user/workspace/SmartFolderTest.java +++ b/src/test/java/org/gcube/portlets/user/workspace/SmartFolderTest.java @@ -1,5 +1,5 @@ /** - * + * */ package org.gcube.portlets.user.workspace; @@ -13,32 +13,38 @@ import org.gcube.common.homelibrary.home.workspace.Workspace; import org.gcube.common.homelibrary.home.workspace.search.SearchItem; import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.impl.ScopeBean; -import org.gcube.portlets.user.workspace.client.interfaces.GXTCategoryItemInterface; +import org.gcube.portlets.user.workspace.client.interfaces.GXTCategorySmartFolder; import org.gcube.portlets.user.workspace.client.model.FileGridModel; import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder; /** - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it - * @Jul 3, 2013 + * The Class SmartFolderTest. * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Sep 29, 2016 */ public class SmartFolderTest { - - + + protected static Logger logger = Logger.getLogger(SmartFolderTest.class); - + // public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps/EcologicalModelling"; //PRODUCTION public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV private static Workspace workspace; - + + /** + * The main method. + * + * @param args the arguments + */ public static void main(String[] args) { try { ScopeBean scope = new ScopeBean(DEFAULT_SCOPE); ScopeProvider.instance.set(scope.toString()); - + System.out.println("instancing workspace"); workspace = HomeLibrary .getHomeManagerFactory() @@ -47,8 +53,8 @@ public class SmartFolderTest { .getWorkspace(); // System.out.println("start"); - List smarts = getSmartFolderResultsByCategory(GXTCategoryItemInterface.SMF_IMAGES); - + List smarts = getSmartFolderResultsByCategory(GXTCategorySmartFolder.SMF_IMAGES); + for (FileGridModel fileGridModel : smarts) { System.out.println(fileGridModel.toString()); } @@ -57,31 +63,38 @@ public class SmartFolderTest { e.printStackTrace(); } } - - public static List getSmartFolderResultsByCategory(String category) throws Exception { - + + /** + * Gets the smart folder results by category. + * + * @param category the category + * @return the smart folder results by category + * @throws Exception the exception + */ + public static List getSmartFolderResultsByCategory(GXTCategorySmartFolder category) throws Exception { + try { - - + + GWTWorkspaceBuilder builder = new GWTWorkspaceBuilder(); - + List listWorkspaceItems = new ArrayList(); - + //Category IMAGES - if(category.equals(GXTCategoryItemInterface.SMF_IMAGES.toString())){ - + if(category.equals(GXTCategorySmartFolder.SMF_IMAGES.toString())){ + listWorkspaceItems = workspace.getFolderItems(FolderItemType.IMAGE_DOCUMENT, FolderItemType.EXTERNAL_IMAGE); - + //Category BIODIVERSITY - }else if(category.equals(GXTCategoryItemInterface.SMF_BIODIVERSITY.toString())){ - + }else if(category.equals(GXTCategorySmartFolder.SMF_BIODIVERSITY.toString())){ + // listWorkspaceItems = workspace.getFolderItems(FolderItemType.AQUAMAPS_ITEM); //Category DOCUMENTS - }else if(category.equals(GXTCategoryItemInterface.SMF_DOCUMENTS.toString())){ - + }else if(category.equals(GXTCategorySmartFolder.SMF_DOCUMENTS.toString())){ + listWorkspaceItems = workspace.getFolderItems( - FolderItemType.EXTERNAL_FILE, + FolderItemType.EXTERNAL_FILE, FolderItemType.EXTERNAL_PDF_FILE, FolderItemType.QUERY, FolderItemType.PDF_DOCUMENT, @@ -91,35 +104,35 @@ public class SmartFolderTest { // FolderItemType.URL_DOCUMENT, FolderItemType.DOCUMENT ); - + //Category LINKS - }else if(category.equals(GXTCategoryItemInterface.SMF_LINKS.toString())){ - + }else if(category.equals(GXTCategorySmartFolder.SMF_LINKS.toString())){ + // listWorkspaceItems = workspace.getFolderItems(FolderItemType.EXTERNAL_URL, FolderItemType.URL_DOCUMENT, FolderItemType.EXTERNAL_RESOURCE_LINK); - + //Category REPORTS - }else if(category.equals(GXTCategoryItemInterface.SMF_REPORTS.toString())){ - + }else if(category.equals(GXTCategorySmartFolder.SMF_REPORTS.toString())){ + listWorkspaceItems = workspace.getFolderItems(FolderItemType.REPORT_TEMPLATE, FolderItemType.REPORT); - + //Category TIME SERIES - }else if(category.equals(GXTCategoryItemInterface.SMF_TIMESERIES.toString())){ - + }else if(category.equals(GXTCategorySmartFolder.SMF_TIMESERIES.toString())){ + listWorkspaceItems = workspace.getFolderItems(FolderItemType.TIME_SERIES); } else new Exception("Smart folder category unknown"); - + return builder.filterListFileGridModelItemByCategory(listWorkspaceItems, category); - + } catch (Exception e) { System.out.println("Error in server get smart folder by category"); e.printStackTrace(); throw new Exception(e.getMessage()); } - + } - + }