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
This commit is contained in:
Costantino Perciante 2016-07-14 08:28:22 +00:00
parent 40b4ae8f50
commit 1ba0ec1f00
1 changed files with 12 additions and 3 deletions

View File

@ -28,6 +28,8 @@ import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager; import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
import org.gcube.vomanagement.usermanagement.model.GCubeUser; import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import eu.trentorise.opendata.jackan.model.CkanLicense;
/** /**
* The Class UserUtil. * The Class UserUtil.
@ -180,11 +182,18 @@ public class UserUtil {
try{ try{
logger.debug("User in session is " + username); logger.debug("User in session is " + username);
List<String> titlesLicenses = ckanUtils.getLicenseTitles(); List<CkanLicense> titlesLicenses = ckanUtils.getLicenses();
LicensesBean licensesBean = new LicensesBean(titlesLicenses); List<String> titles = new ArrayList<String>();
List<String> urls = new ArrayList<String>();
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); session.setAttribute(ckanLicensesKey, licensesBean);
logger.info("List of licenses has been saved into session" + licensesBean); logger.info("List of licenses has been saved into session" + licensesBean);
} }
catch(Exception e){ catch(Exception e){
logger.error("Failed to preload licenses list", e); logger.error("Failed to preload licenses list", e);