diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 4e4a3ad..cac0df4 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -3,7 +3,9 @@ org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore org.eclipse.jdt.core.compiler.release=disabled org.eclipse.jdt.core.compiler.source=1.8 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index f71b472..c3e19fb 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,10 +1,19 @@ + + + + + + + + + diff --git a/CHANGELOG.md b/CHANGELOG.md index 48bbe40..cd9314b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v1.1.2-SNAPSHOT] - 2023-02-13 + +- bug fix + ## [v1.1.1] - 2021-10-13 - Feature #22177, Modify Catalogue widget portlet to display the types and the number when in root VO diff --git a/pom.xml b/pom.xml index 084e403..72a9d87 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ catalogue-badge-portlet war Catalogue-badge-portlet Portlet - 1.1.1 + 1.1.2-SNAPSHOT Catalogue badge portlet displays a synoptic view of the catalogue content @@ -38,7 +38,7 @@ org.gcube.distribution maven-portal-bom - 3.6.3 + 3.6.4-SNAPSHOT pom import @@ -51,14 +51,13 @@ [2.4.1-SNAPSHOT, 3.0.0-SNAPSHOT) compile - - org.gcube.dvos - usermanagement-core - org.gcube.common.portal portal-manager - provided + + + org.gcube.dvos + usermanagement-core org.jsoup diff --git a/src/main/java/org/gcube/portlets/user/cataloguebadge/CatalogueBadgeConfigurationAction.java b/src/main/java/org/gcube/portlets/user/cataloguebadge/CatalogueBadgeConfigurationAction.java index d547ef0..49e08d4 100644 --- a/src/main/java/org/gcube/portlets/user/cataloguebadge/CatalogueBadgeConfigurationAction.java +++ b/src/main/java/org/gcube/portlets/user/cataloguebadge/CatalogueBadgeConfigurationAction.java @@ -22,7 +22,7 @@ public class CatalogueBadgeConfigurationAction extends DefaultConfigurationActio PortletPreferences prefs = actionRequest.getPreferences(); String catalogueURL = prefs.getValue("catalogueURL", "true"); - + _log.debug("catalogueURL = " + catalogueURL + " in CatalogueBadgeConfigurationAction.processAction()."); } diff --git a/src/main/java/org/gcube/portlets/user/cataloguebadge/PortletViewController.java b/src/main/java/org/gcube/portlets/user/cataloguebadge/PortletViewController.java index 807b8cd..9f5c6d2 100644 --- a/src/main/java/org/gcube/portlets/user/cataloguebadge/PortletViewController.java +++ b/src/main/java/org/gcube/portlets/user/cataloguebadge/PortletViewController.java @@ -1,16 +1,3 @@ -/** - * Copyright (c) 2000-present Liferay, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - */ package org.gcube.portlets.user.cataloguebadge; @@ -56,7 +43,7 @@ import com.liferay.portal.util.PortalUtil; @RequestMapping("VIEW") public class PortletViewController { private static Log _log = LogFactoryUtil.getLog(PortletViewController.class); - private static final String IMAGES_BASE_URL = "https://catalogue.d4science.org/"; +// private static final String IMAGES_BASE_URL = "https://catalogue.d4science.org/"; private static final long K = 1000; private static final long M = K * K; private static final long G = M * K; @@ -68,7 +55,18 @@ public class PortletViewController { model.addAttribute("releaseInfo", ReleaseInfo.getReleaseInfo()); PortletPreferences prefs = request.getPreferences(); String catalogueBaseURL = GetterUtil.getString(prefs.getValue("catalogueURL", StringPool.BLANK)); + String catalogueTypes2Show = GetterUtil.getString(prefs.getValue("catalogueTypes2ShowNo", StringPool.BLANK)); + int typesNo = 5; + if (catalogueTypes2Show != null && !catalogueTypes2Show.equals(StringPool.BLANK)) { + try{ + typesNo = Integer.parseInt(catalogueTypes2Show); + } catch (Exception e) { + System.out.println(e.getMessage()); + typesNo = 5; + } + } model.addAttribute("catalogueActualURL", catalogueBaseURL); + HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(request); long groupId = -1; boolean isRootVO = false; @@ -83,10 +81,13 @@ public class PortletViewController { model.addAttribute("isRootVO", isRootVO); if (catalogueBaseURL != null && catalogueBaseURL.compareTo("") != 0) { //if the config textbox with catalogueURL is filled in we show the types try { - List theTypes = parseTypes(catalogueBaseURL+"/type", catalogueURL); + List theTypes = parseTypes(catalogueBaseURL+"/type", catalogueURL, catalogueBaseURL); Collections.sort(theTypes, Collections.reverseOrder()); List theFiveTypes = new ArrayList<>(); - for (int i = 0; i < 6; i++) { + int limit = typesNo-1; + if (theTypes.size() <= limit) + limit = theTypes.size()-1; + for (int i = 0; i <= limit; i++) { theFiveTypes.add(theTypes.get(i)); } model.addAttribute("catalogueTypes", theFiveTypes); @@ -135,7 +136,7 @@ public class PortletViewController { return "Catalogue-badge-portlet/view"; } - private List parseTypes(String url, String catalogueURL) throws Exception { + private List parseTypes(String url, String catalogueURL, String catalogueBaseURL) throws Exception { List toReturn = new ArrayList<>(); Document doc = Jsoup.connect(url) .userAgent("Mozilla") @@ -165,7 +166,7 @@ public class PortletViewController { } catch (Exception e) { _log.error("Could not find occurrence in string "+ nameAndOccurrence); } - toReturn.add(new CatalogueType(name, IMAGES_BASE_URL+imgUrl, hrefPortlet, occurrence)); + toReturn.add(new CatalogueType(name, catalogueBaseURL+imgUrl, hrefPortlet, occurrence)); } return toReturn; } diff --git a/src/main/webapp/WEB-INF/jsp/Catalogue-badge-portlet/config.jsp b/src/main/webapp/WEB-INF/jsp/Catalogue-badge-portlet/config.jsp index a4a1065..7da9798 100644 --- a/src/main/webapp/WEB-INF/jsp/Catalogue-badge-portlet/config.jsp +++ b/src/main/webapp/WEB-INF/jsp/Catalogue-badge-portlet/config.jsp @@ -18,6 +18,8 @@ <% String appURL_cfg = GetterUtil.getString(portletPreferences.getValue("catalogueURL", StringPool.BLANK)); + +String types2Show_cfg = GetterUtil.getString(portletPreferences.getValue("catalogueTypes2ShowNo", StringPool.BLANK)); %> @@ -32,6 +34,14 @@ String appURL_cfg = GetterUtil.getString(portletPreferences.getValue("catalogueU placeholder="Enter Catalogue URL (e.g. https://ckan-sobigdata.d4science.org)" helpMessage="Actual endpoint of the ckan instance (e.g. https://ckan-sobigdata.d4science.org)" value="<%=appURL_cfg%>" required="false" /> + + + diff --git a/src/main/webapp/WEB-INF/jsp/Catalogue-badge-portlet/view.jsp b/src/main/webapp/WEB-INF/jsp/Catalogue-badge-portlet/view.jsp index 66ab1a3..2a0bdec 100644 --- a/src/main/webapp/WEB-INF/jsp/Catalogue-badge-portlet/view.jsp +++ b/src/main/webapp/WEB-INF/jsp/Catalogue-badge-portlet/view.jsp @@ -1,24 +1,24 @@ <%@ page contentType="text/html" pageEncoding="UTF-8"%> -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> -<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %> -<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %> -<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %> -<%@ page import="com.liferay.portal.kernel.util.Constants" %> -<%@ page import="com.liferay.portal.kernel.util.GetterUtil" %> -<%@ page import="com.liferay.portal.kernel.util.StringPool" %> -<%@ page import="com.liferay.portal.util.PortalUtil" %> +<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui"%> +<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet"%> +<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme"%> +<%@ page import="com.liferay.portal.kernel.util.Constants"%> +<%@ page import="com.liferay.portal.kernel.util.GetterUtil"%> +<%@ page import="com.liferay.portal.kernel.util.StringPool"%> +<%@ page import="com.liferay.portal.util.PortalUtil"%> - + - - - - - -
-
+
+
+
+
@@ -32,26 +32,23 @@ href="${catalogueURL}?path=/types" style="float: right;">See All Types
-
- - - - - - -
${type.name} - -

- - ${type.name} (${type.occurrence}) -

-
+ + + +