From 1ba0ec1f0099e93e02e7098194b585b682a6a131 Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Thu, 14 Jul 2016 08:28:22 +0000 Subject: [PATCH] getLicenses method fixed git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@130338 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../user/workspace/server/util/UserUtil.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/util/UserUtil.java b/src/main/java/org/gcube/portlets/user/workspace/server/util/UserUtil.java index 5541daf..522e7ae 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/util/UserUtil.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/util/UserUtil.java @@ -28,6 +28,8 @@ import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault; import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager; import org.gcube.vomanagement.usermanagement.model.GCubeUser; +import eu.trentorise.opendata.jackan.model.CkanLicense; + /** * The Class UserUtil. @@ -180,11 +182,18 @@ public class UserUtil { try{ logger.debug("User in session is " + username); - List titlesLicenses = ckanUtils.getLicenseTitles(); - LicensesBean licensesBean = new LicensesBean(titlesLicenses); + List titlesLicenses = ckanUtils.getLicenses(); + List titles = new ArrayList(); + List urls = new ArrayList(); + for (CkanLicense license : titlesLicenses) { + titles.add(license.getTitle()); + String url = (license.getUrl() != null && !license.getUrl().isEmpty()) ? license.getUrl() : ""; + urls.add(url); + } + LicensesBean licensesBean = new LicensesBean(titles, urls); + session.setAttribute(ckanLicensesKey, licensesBean); logger.info("List of licenses has been saved into session" + licensesBean); - } catch(Exception e){ logger.error("Failed to preload licenses list", e);