aggiunto porting md e piccolo fix
This commit is contained in:
parent
5139369517
commit
e43bca50ce
|
|
@ -0,0 +1,55 @@
|
|||
# Porting VLabs Display Portlet (Liferay 6.2 → 7.4)
|
||||
|
||||
## Obiettivo e Stato
|
||||
- Obiettivo: portare la portlet “Virtual Labs Display” da Liferay 6.2 a Liferay 7.4 mantenendo funzionalità e UI.
|
||||
- Esito: funzionalità e UI paritarie. La portlet 7.4 espone le stesse 9 voci configurabili (Icon URL, Title, DocumentId, URL), calcola access policy e URL friendly del VRE in base alla membership utente, e visualizza contenuto dei JournalArticle con sommario e “Read More”.
|
||||
|
||||
## Funzionalità chiave (paritarie)
|
||||
- Configurazione per 9 VLabs: per ogni voce si gestiscono Icon URL, Title, DocumentId, URL del VRE.
|
||||
- Calcolo membership VRE e friendly URL: via utilità [Utils.java](file:///Users/netfarm-m2/Desktop/kb_liferay/porting_liferay/porting_liferay_cnr/modules/portal-vlabs-display-portlet/src/main/java/org/gcube/portlets/user/vlabs/Utils.java).
|
||||
- Contenuti CMS: lettura del contenuto del JournalArticle per il groupId corrente e docId configurato.
|
||||
- UI: titolo con icona, badge access policy (open/restricted/private) e sommario con toggle “Read More”.
|
||||
|
||||
## Differenze tecniche principali
|
||||
- Registrazione portlet:
|
||||
- 6.2: MVCPortlet senza logica in classe; configurazione in [liferay-portlet.xml](file:///Users/netfarm-m2/Desktop/kb_liferay/porting_liferay/porting_liferay_cnr/cancellare/vlabs-display-portlet/src/main/webapp/WEB-INF/liferay-portlet.xml) e [portlet.xml](file:///Users/netfarm-m2/Desktop/kb_liferay/porting_liferay/porting_liferay_cnr/cancellare/vlabs-display-portlet/src/main/webapp/WEB-INF/portlet.xml).
|
||||
- 7.4: componente OSGi [VLabsDisplay.java](file:///Users/netfarm-m2/Desktop/kb_liferay/porting_liferay/porting_liferay_cnr/modules/portal-vlabs-display-portlet/src/main/java/org/gcube/portlets/user/vlabs/VLabsDisplay.java) con proprietà; XML mantenuti per compatibilità (CSS/JS e wrapper class).
|
||||
- API Journal:
|
||||
- 6.2: com.liferay.portlet.journal.* in JSP [init.jsp](file:///Users/netfarm-m2/Desktop/kb_liferay/porting_liferay/porting_liferay_cnr/cancellare/vlabs-display-portlet/src/main/webapp/html/vlabsdisplay/init.jsp).
|
||||
- 7.4: com.liferay.journal.* in JSP [init.jsp](file:///Users/netfarm-m2/Desktop/kb_liferay/porting_liferay/porting_liferay_cnr/modules/portal-vlabs-display-portlet/src/main/webapp/html/vlabsdisplay/init.jsp).
|
||||
- Generazione id “Read More”:
|
||||
- 6.2: id randomizzati per evitare collisioni tra istanze (in-page).
|
||||
- 7.4: allineato con prefisso random + indice in [view.jsp](file:///Users/netfarm-m2/Desktop/kb_liferay/porting_liferay/porting_liferay_cnr/modules/portal-vlabs-display-portlet/src/main/webapp/html/vlabsdisplay/view.jsp#L67-L76).
|
||||
- Helper contenuti:
|
||||
- 6.2: la JSP legge direttamente i contenuti dal JournalArticle.
|
||||
- 7.4: mantenuto lo stesso approccio; l’istanza di helper non iniettata è stata rimossa da VLabsDisplay per evitare codice morto e incoerente con OSGi.
|
||||
|
||||
## Mappatura preferenze (6.2 ↔ 7.4)
|
||||
- icondocURL, icondocURLWidthPx
|
||||
- vlabNameN-Icon, vlabNameN-Title, vlabNameN-DocumentId (N = 1..9)
|
||||
- vlabN-Url (N = 1..9)
|
||||
- Le chiavi sono invariate, non è necessaria migrazione delle preferences.
|
||||
|
||||
## File principali
|
||||
- Classe portlet: [VLabsDisplay.java](file:///Users/netfarm-m2/Desktop/kb_liferay/porting_liferay/porting_liferay_cnr/modules/portal-vlabs-display-portlet/src/main/java/org/gcube/portlets/user/vlabs/VLabsDisplay.java)
|
||||
- Azione di configurazione: [VLabsDisplayConfigurationAction.java](file:///Users/netfarm-m2/Desktop/kb_liferay/porting_liferay/porting_liferay_cnr/modules/portal-vlabs-display-portlet/src/main/java/org/gcube/portlets/user/vlabs/VLabsDisplayConfigurationAction.java)
|
||||
- Utilità membership/URL: [Utils.java](file:///Users/netfarm-m2/Desktop/kb_liferay/porting_liferay/porting_liferay_cnr/modules/portal-vlabs-display-portlet/src/main/java/org/gcube/portlets/user/vlabs/Utils.java)
|
||||
- JSP:
|
||||
- View: [view.jsp](file:///Users/netfarm-m2/Desktop/kb_liferay/porting_liferay/porting_liferay_cnr/modules/portal-vlabs-display-portlet/src/main/webapp/html/vlabsdisplay/view.jsp)
|
||||
- Config: [config.jsp](file:///Users/netfarm-m2/Desktop/kb_liferay/porting_liferay/porting_liferay_cnr/modules/portal-vlabs-display-portlet/src/main/webapp/html/vlabsdisplay/config.jsp)
|
||||
- Init: [init.jsp](file:///Users/netfarm-m2/Desktop/kb_liferay/porting_liferay/porting_liferay_cnr/modules/portal-vlabs-display-portlet/src/main/webapp/html/vlabsdisplay/init.jsp)
|
||||
- Risorse:
|
||||
- CSS: [main.css](file:///Users/netfarm-m2/Desktop/kb_liferay/porting_liferay/porting_liferay_cnr/modules/portal-vlabs-display-portlet/src/main/webapp/css/main.css)
|
||||
- JS: [main.js](file:///Users/netfarm-m2/Desktop/kb_liferay/porting_liferay/porting_liferay_cnr/modules/portal-vlabs-display-portlet/src/main/webapp/js/main.js)
|
||||
- Icone access policy: [images](file:///Users/netfarm-m2/Desktop/kb_liferay/porting_liferay/porting_liferay_cnr/modules/portal-vlabs-display-portlet/src/main/webapp/images)
|
||||
- Descriptor:
|
||||
- [liferay-portlet.xml](file:///Users/netfarm-m2/Desktop/kb_liferay/porting_liferay/porting_liferay_cnr/modules/portal-vlabs-display-portlet/src/main/webapp/WEB-INF/liferay-portlet.xml)
|
||||
- [portlet.xml](file:///Users/netfarm-m2/Desktop/kb_liferay/porting_liferay/porting_liferay_cnr/modules/portal-vlabs-display-portlet/src/main/webapp/WEB-INF/portlet.xml)
|
||||
- [bnd.bnd](file:///Users/netfarm-m2/Desktop/kb_liferay/porting_liferay/porting_liferay_cnr/modules/portal-vlabs-display-portlet/bnd.bnd)
|
||||
- [build.gradle](file:///Users/netfarm-m2/Desktop/kb_liferay/porting_liferay/porting_liferay_cnr/modules/portal-vlabs-display-portlet/build.gradle)
|
||||
|
||||
## Build e Requisiti
|
||||
- Dipendenze: Liferay release.portal.api, portal-manager-core, portal-usermanagement-core, JSTL.
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,22 +1,10 @@
|
|||
package org.gcube.portlets.user.vlabs;
|
||||
|
||||
import com.liferay.portal.kernel.exception.PortalException;
|
||||
import com.liferay.portal.kernel.log.Log;
|
||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||
import com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet;
|
||||
import com.liferay.portal.kernel.theme.ThemeDisplay;
|
||||
import com.liferay.portal.kernel.util.PortalUtil;
|
||||
import com.liferay.portal.kernel.util.GetterUtil;
|
||||
import com.liferay.portal.kernel.model.User;
|
||||
import org.osgi.service.component.annotations.Component;
|
||||
import org.osgi.service.component.annotations.Reference;
|
||||
|
||||
import javax.portlet.Portlet;
|
||||
import javax.portlet.RenderRequest;
|
||||
import javax.portlet.RenderResponse;
|
||||
import javax.portlet.PortletException;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Portlet implementation class VLabsDisplay
|
||||
*/
|
||||
|
|
@ -34,35 +22,4 @@ import java.io.IOException;
|
|||
public class VLabsDisplay extends MVCPortlet {
|
||||
|
||||
private static Log _log = LogFactoryUtil.getLog(VLabsDisplay.class);
|
||||
|
||||
private JournalArticleHelper journalArticleHelper = new JournalArticleHelper(); // helper per recuperare i contenuti
|
||||
|
||||
@Override
|
||||
public void doView(RenderRequest renderRequest, RenderResponse renderResponse)
|
||||
throws IOException, PortletException {
|
||||
|
||||
ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute("LIFERAY_SHARED_THEME_DISPLAY");
|
||||
try {
|
||||
User currentUser = PortalUtil.getUser(renderRequest);
|
||||
} catch (PortalException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
long groupId = themeDisplay.getScopeGroupId();
|
||||
|
||||
// esempio per VLab1
|
||||
long vlabName1DocumentId = GetterUtil.getLong(
|
||||
renderRequest.getPreferences().getValue("vlabName1-DocumentId", "0")
|
||||
);
|
||||
|
||||
String content1 = "";
|
||||
if (vlabName1DocumentId > 0) {
|
||||
content1 = journalArticleHelper.getArticleContent(groupId, vlabName1DocumentId);
|
||||
}
|
||||
renderRequest.setAttribute("content1", content1);
|
||||
|
||||
// Qui puoi ripetere per gli altri VLab (2,3,...9) usando journalArticleHelper
|
||||
|
||||
super.doView(renderRequest, renderResponse);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,9 +65,14 @@
|
|||
|
||||
|
||||
<c:if test="${not empty vlab.title}">
|
||||
|
||||
<c:set var="preId" value="assetAppSummaryPre${st.index}" />
|
||||
<c:set var="contentId" value="assetAppSummary${st.index}" />
|
||||
<%
|
||||
java.util.Random _vlabsRand = new java.util.Random();
|
||||
final int _VLABS_MAX_NUMBER = 999999;
|
||||
int _rndBase = _vlabsRand.nextInt(_VLABS_MAX_NUMBER);
|
||||
pageContext.setAttribute("rndBase", _rndBase);
|
||||
%>
|
||||
<c:set var="preId" value="assetAppSummaryPre${rndBase}${st.index}" />
|
||||
<c:set var="contentId" value="assetAppSummary${rndBase}${st.index}" />
|
||||
|
||||
<div class="asset-abstract">
|
||||
<h3 class="asset-title">
|
||||
|
|
|
|||
Loading…
Reference in New Issue