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; }