From 75046a3920e864e053d356af2b4c9146a1b8d9ef Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Fri, 7 Oct 2016 10:49:37 +0000 Subject: [PATCH] handled more errors while retreving folder's files git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@132923 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../server/utils/WorkspaceUtils.java | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/WorkspaceUtils.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/WorkspaceUtils.java index 01427d8..10c75e7 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/WorkspaceUtils.java +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/WorkspaceUtils.java @@ -85,7 +85,7 @@ public class WorkspaceUtils { // return return resources; } - + /** * This method receives a folder id within the user's workspace and set the list of resources in the dataset bean to be returned * @param folderId @@ -123,29 +123,26 @@ public class WorkspaceUtils { } } - List listOfResources = getWorkspaceResourcesInformation(childrenIds, ws, userName); - bean.setResources(listOfResources); + // set them into the bean + bean.setResources(getWorkspaceResourcesInformation(childrenIds, ws, userName)); } - + /** * Build up the resource beans. * @param resourceIds * @param ws * @param username - * @return + * @return a list of resource wrapper beans */ public static List getWorkspaceResourcesInformation( - List resourceIds, Workspace ws, String username) { + List resourceIds, Workspace ws, String username){ - List toReturn = null; + List toReturn = new ArrayList<>(); - try{ - - toReturn = new ArrayList<>(); - - for (String resourceId : resourceIds) { + for (String resourceId : resourceIds) { + try{ logger.debug("RESOURCE ID IS " + resourceId); ResourceBeanWrapper newResource = new ResourceBeanWrapper(); @@ -157,12 +154,12 @@ public class WorkspaceUtils { newResource.setToBeAdded(true); // default is true newResource.setMimeType(((FolderItem)item).getMimeType()); toReturn.add(newResource); - + }catch(Exception e ){ + logger.error("Unable to add resource with id " + resourceId + " to the product bean"); } - }catch(Exception e){ - logger.error("Unable to retrieve resources' info", e); - } + } + return toReturn; }