From c60edde5209678b3e5454e6d910300b1eb16a1ac Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Tue, 9 Apr 2019 10:07:09 +0000 Subject: [PATCH] Rebuilt due to storagehub exceptions added since gCube 4.14 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-explorer@178951 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 2 + .settings/org.eclipse.jdt.core.prefs | 1 + ...se.wst.common.project.facet.core.prefs.xml | 7 ++ ....eclipse.wst.common.project.facet.core.xml | 1 + distro/changelog.xml | 54 +++++++---- pom.xml | 2 +- .../wsexplorer/server/ItemBuilder.java | 9 +- .../server/WorkspaceExplorerServiceImpl.java | 9 +- .../server/stohub/StorageHubServiceUtil.java | 94 +++++++++++++++++-- 9 files changed, 149 insertions(+), 30 deletions(-) create mode 100644 .settings/org.eclipse.wst.common.project.facet.core.prefs.xml diff --git a/.classpath b/.classpath index 3dfcb58..b2345ff 100644 --- a/.classpath +++ b/.classpath @@ -16,11 +16,13 @@ + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index b257af7..a5c7673 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -5,4 +5,5 @@ org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.release=disabled org.eclipse.jdt.core.compiler.source=1.7 diff --git a/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml b/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml new file mode 100644 index 0000000..cc81385 --- /dev/null +++ b/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml index 735eb31..dcd7752 100644 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -4,4 +4,5 @@ + diff --git a/distro/changelog.xml b/distro/changelog.xml index a0f2972..0212e37 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -1,10 +1,18 @@ - + Rebuilt due to storagehub exceptions added since gCube 4.14 + + + Changed ItemBuilder to read the new method getMetadata - [Incident #77436] Fixing class cast Exception for FolderItem son of a SharedFolder @@ -14,72 +22,86 @@ Fixed breadcrumb on SelectDialaog - [Task #10943] Migrated to StorageHub - [Task #10943] Added breadcrumb changed event - [Feature #9114] Add pagination to Workspace Explorer - [Bug #6601] fixed - Removed ASL Dependency, ported to gCube Client Context - [Feature #5091] Added load for folder ID to SelectDialog and SelectPanel Bug fixed on breadcrumb when item is null - [Feature #4128] Migration to Liferay 6.2 - [Feature #2546] Endow Workspace Resources Explorer with filtering and display features - [Incident #2903] Bug fixed - Bug fix in Item.java [Bug #2350] Bug fix - Bug fix in Item.java [Bug #2350] Bug fix - [Feature #1657] Added Resource Explorer Feature #2099] Add new facility: create a new folder - First Release - Started project diff --git a/pom.xml b/pom.xml index b8baf3f..9573e4e 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ 4.0.0 org.gcube.portlets.widgets workspace-explorer - 2.1.0-SNAPSHOT + 2.1.1-SNAPSHOT gCube Workspace Explorer gCube Workspace Explorer widget allows to navigate (gCube) Workspace diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/ItemBuilder.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/ItemBuilder.java index 2327b2f..5f379ea 100644 --- a/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/ItemBuilder.java +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/ItemBuilder.java @@ -37,6 +37,7 @@ import org.slf4j.LoggerFactory; public class ItemBuilder { public static final Logger _log = LoggerFactory.getLogger(ItemBuilder.class); + /** * Gets the item. * @@ -48,11 +49,11 @@ public class ItemBuilder { * @param loadChildren the load children * @param loadGcubeProperties the load gcube properties * @return the item - * @throws InternalErrorException the internal error exception + * @throws Exception the exception */ public static org.gcube.portlets.widgets.wsexplorer.shared.Item getItem(org.gcube.portlets.widgets.wsexplorer.shared.Item parent, Item workspaceItem, String workspaceItemPath, List showableTypes, FilterCriteria filterCriteria, - boolean loadChildren, boolean loadGcubeProperties) { + boolean loadChildren, boolean loadGcubeProperties) throws Exception { ItemType type = getItemType(workspaceItem); @@ -123,11 +124,11 @@ public class ItemBuilder { * @param startIdx the start idx * @param limit the limit * @return the item - * @throws InternalErrorException the internal error exception + * @throws Exception the exception */ public static org.gcube.portlets.widgets.wsexplorer.shared.Item getItem(org.gcube.portlets.widgets.wsexplorer.shared.Item parent, Item workspaceItem, String workspaceItemPath, List showableTypes, FilterCriteria filterCriteria, - boolean loadChildren, boolean loadGcubeProperties, int startIdx, int limit) { + boolean loadChildren, boolean loadGcubeProperties, int startIdx, int limit) throws Exception { ItemType type = getItemType(workspaceItem); diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/WorkspaceExplorerServiceImpl.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/WorkspaceExplorerServiceImpl.java index 1f99a6c..7bbce1d 100644 --- a/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/WorkspaceExplorerServiceImpl.java +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/WorkspaceExplorerServiceImpl.java @@ -377,7 +377,7 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement try { return StorageHubServiceUtil.getUserACLForFolderId(getThreadLocalRequest(), folderId); }catch(Exception e) { - e.printStackTrace(); + _log.info("Error on getUserACLForFolderId",e); } return "UNKNOWN"; } @@ -568,7 +568,12 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement @Override public int getFolderChildrenCount(org.gcube.portlets.widgets.wsexplorer.shared.Item item){ - return StorageHubServiceUtil.getItemChildrenCount(getThreadLocalRequest(), item.getId()); + try { + return StorageHubServiceUtil.getItemChildrenCount(getThreadLocalRequest(), item.getId()); + } catch (Exception e) { + _log.error("Error on getFolderChildrenCount", e); + return 0; + } } diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/stohub/StorageHubServiceUtil.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/stohub/StorageHubServiceUtil.java index b64653c..5f213a4 100644 --- a/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/stohub/StorageHubServiceUtil.java +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/stohub/StorageHubServiceUtil.java @@ -20,10 +20,23 @@ import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; +/** + * The Class StorageHubServiceUtil. + * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * + * Apr 9, 2019 + */ public class StorageHubServiceUtil { private static Log _log = LogFactoryUtil.getLog(StorageHubServiceUtil.class); public static final String ACCOUNTING_HL_NODE_NAME = "hl:accounting"; + /** + * Gets the root. + * + * @param request the request + * @return the root + */ public static Item getRoot(HttpServletRequest request) { PortalContext pContext = PortalContext.getConfiguration(); String userName = pContext.getCurrentUser(request).getUsername(); @@ -35,8 +48,44 @@ public class StorageHubServiceUtil { Item itemRoot = client.getWorkspace(ACCOUNTING_HL_NODE_NAME); return itemRoot; } + +// /** +// * Gets the notification manager to storage hub. +// * +// * @param httpServletRequest the http servlet request +// * @return the notification manager to storage hub +// */ +// public static NotificationsManager getNotificationManagerToStorageHub(HttpServletRequest httpServletRequest) +// { +// PortalContextInfo info = getPortalContext(httpServletRequest); +// HttpSession session = httpServletRequest.getSession(); +// NotificationsManager notifMng = (NotificationsManager) session.getAttribute(NOTIFICATION_MANAGER_TO_STORAGEHUB); +// +// if (notifMng == null) { +// try{ +// logger.trace("Create new NotificationsManager for user: "+info.getUsername()); +// logger.trace("New ApplicationNotificationsManager with portlet class name: "+NOTIFICATION_PORTLET_CLASS_ID); +// SocialNetworkingSite site = new SocialNetworkingSite(httpServletRequest); +// SocialNetworkingUser curser = new SocialNetworkingUser(info.getUsername(), info.getUserEmail(), info.getUserFullName(), info.getUserAvatarID()); +// notifMng = new ApplicationNotificationsManager(site, info.getCurrentScope(), curser, NOTIFICATION_PORTLET_CLASS_ID); +// session.setAttribute(NOTIFICATION_MANAGER_TO_STORAGEHUB, notifMng); +// }catch (Exception e) { +// logger.error("An error occurred instancing ApplicationNotificationsManager for user: "+info.getUsername(),e); +// } +// } +// +// return notifMng; +// } - public static Item getItem(HttpServletRequest request, String itemId) { + /** + * Gets the item. + * + * @param request the request + * @param itemId the item id + * @return the item + * @throws Exception the exception + */ +public static Item getItem(HttpServletRequest request, String itemId) throws Exception { PortalContext pContext = PortalContext.getConfiguration(); String userName = pContext.getCurrentUser(request).getUsername(); String scope = pContext.getCurrentScope(request); @@ -48,7 +97,15 @@ public class StorageHubServiceUtil { return toReturn; } - public static List getParents(HttpServletRequest request, String itemId) { + /** + * Gets the parents. + * + * @param request the request + * @param itemId the item id + * @return the parents + * @throws Exception the exception + */ + public static List getParents(HttpServletRequest request, String itemId) throws Exception { PortalContext pContext = PortalContext.getConfiguration(); String userName = pContext.getCurrentUser(request).getUsername(); String scope = pContext.getCurrentScope(request); @@ -60,7 +117,17 @@ public class StorageHubServiceUtil { return toReturn; } - public static FolderItem createFolder(HttpServletRequest request, String parentId, String name, String description) { + /** + * Creates the folder. + * + * @param request the request + * @param parentId the parent id + * @param name the name + * @param description the description + * @return the folder item + * @throws Exception the exception + */ + public static FolderItem createFolder(HttpServletRequest request, String parentId, String name, String description) throws Exception { PortalContext pContext = PortalContext.getConfiguration(); String userName = pContext.getCurrentUser(request).getUsername(); String scope = pContext.getCurrentScope(request); @@ -73,8 +140,9 @@ public class StorageHubServiceUtil { } /** + * Gets the VRE folders id. * - * @param request + * @param request the request * @return the VRE Folders Id */ public static String getVREFoldersId(HttpServletRequest request) { @@ -101,7 +169,15 @@ public class StorageHubServiceUtil { } - public static String getUserACLForFolderId(HttpServletRequest request, String folderId) { + /** + * Gets the user ACL for folder id. + * + * @param request the request + * @param folderId the folder id + * @return the user ACL for folder id + * @throws Exception the exception + */ + public static String getUserACLForFolderId(HttpServletRequest request, String folderId) throws Exception { PortalContext pContext = PortalContext.getConfiguration(); String userName = pContext.getCurrentUser(request).getUsername(); String scope = pContext.getCurrentScope(request); @@ -151,11 +227,15 @@ public class StorageHubServiceUtil { return "UNDEFINED"; } - /** + * Gets the item children count. * + * @param request the request + * @param itemId the item id + * @return the item children count + * @throws Exception the exception */ - public static int getItemChildrenCount(HttpServletRequest request, String itemId) { + public static int getItemChildrenCount(HttpServletRequest request, String itemId) throws Exception { PortalContext pContext = PortalContext.getConfiguration(); String userName = pContext.getCurrentUser(request).getUsername(); String scope = pContext.getCurrentScope(request);