SlideShare uma empresa Scribd logo
1 de 33
Baixar para ler offline
Using Plugins to Extend and
Customize Liferay
Andrea Di Giorgi
R&D Engineer, SMC Treviso
Portlet JSR-286
Punti di Estensione

Utilizzo API pubbliche
Modifica implementazioni classi (Spring e properties)

Modifica pagine JSP
Utilizzo API private
Modifica codice sorgente
Plugins
portlets

hooks

themes

ext

layouttpls

webs
hooks
Modifica properties (alcune)
Modifica traduzioni
Aggiunta e modifica pagine JSP
Nuovi Indexer Post Processor

Nuove implementazioni servizi generati via Service Builder
Nuovi Servlet Filter
Modifica Action Struts
Portlet + Hook per ModelListener, integrazioni
nei portlet core di Liferay, ecc.
ext
Modifica properties non supportate dagli hook

Nuove implementazioni per i bean dichiarati tramite Spring o
properties
Modifica impostazioni dei portlet standard Liferay
liferay-portlet.xml e portlet-custom.xml

Nuove taglib e servizi di utilità
Sovrascrittura diretta di classi
hooks

ext

Modulari

Massima personalizzazione

Hot deployment
Hot undeployment

Il deployment richiede il
riavvio del portale e il
redeploy degli altri plugin

Modifiche reversibili

Undeployment «difficoltoso»
Ridotta manutenibilità
Hook ove possibile

Estendere/includere, non sovrascrivere
Un solo plugin ext
Non sovrascrivere classi
Plugins Architecture
Plugins SDK
Ambiente di sviluppo per i plugin Liferay

Basato su Apache Ant
Richiede un bundle Liferay locale

Supporto per Maven in fase di sviluppo

Un Plugins SDK per ciascun progetto «portale»
Versionare l’intero Plugins SDK
1 directory del Plugins SDK
in /portlets, /hooks, ecc.


1 progetto Eclipse/Liferay IDE

1 plugin Liferay

1 file .war

1 webapp
Plugin Deployment
HookAutoDeployListener
PortletAutoDeployListener

AutoDeployScanner

HookHotDeployListener
PortletHotDeployListener

ThemeAutoDeployListener

PluginContextListener

…

…

/deploy

ThemeHotDeployListener

/webapps
Class Loading
JDK Classloader(s)

App Server Classloader(s)

portal-service.jar

Portal Impl

Plugin A

Plugin B

util-bridges.jar
util-java.jar
util-taglib.jar
Class Loading
Tutto il codice eseguito nel contesto del plugin

Classi Java eseguite nel contesto del plugin
Pagine JSP eseguite nel contesto del portale

Tutto il codice eseguito nel contesto del portale
Class Loading
PortalClassInvoker
Invocare un metodo di una classe del portale da un plugin

PortletActionInvoker
Invocare una Action Struts del portale da un plugin

PortletClassInvoker
Invocare un metodo di una classe di un plugin da un altro
plugin
Esempi
Servlet
Codice eseguito nel contesto del plugin

Basic Authentication
Controllo dei permessi basato sul PermissionChecker

Definizione in web.xml
servlet
SecureFilter

ServletAuthorizingFilter
http://issues.liferay.com/browse/LEP-4682
Esempio
Contenuto di un file della Document Library dato il suo
fileEntryId
Basic Authentication
Controllo del permesso di visualizzazione

 http://localhost:8080/authenticated-servlet-hook/file_entry/42
web.xml
<filter>
<filter-name>Secure Filter</filter-name>
<filter-class>
com.liferay.portal.kernel.servlet.PortalClassLoaderFilter
</filter-class>
<init-param>
<param-name>filter-class</param-name>
<param-value>
com.liferay.portal.servlet.filters.secure.SecureFilter
</param-value>
</init-param>
<init-param>
<param-name>basic_auth</param-name>
<param-value>true</param-value>
</init-param>
</filter>
web.xml
<filter>
<filter-name>Servlet Authorizing Filter</filter-name>
<filter-class>
com.liferay.portal.kernel.servlet.PortalClassLoaderFilter
</filter-class>
<init-param>
<param-name>filter-class</param-name>
<param-value>
com.liferay.portal.servlet.filters.servletauthorizing.ServletAuthorizingFilter
</param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name>Secure Filter</filter-name>
<url-pattern>/file_entry/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>Servlet Authorizing Filter</filter-name>
<url-pattern>/file_entry/*</url-pattern>
</filter-mapping>
web.xml
<servlet>
<servlet-name>File Entry Servlet</servlet-name>
<servlet-class>com.sympo.servlet.FileEntryServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>File Entry Servlet</servlet-name>
<url-pattern>/file_entry/*</url-pattern>
</servlet-mapping>
JSON Web Service
Servizi remoti di un plugin esposti come Web Service JSON

Basic/Digest Authentication

http://www.liferay.com/documentation/
liferay-portal/6.1/development//ai/json-web-services

Controllo dei permessi basato sul PermissionChecker

Deserializzazione automatica degli argomenti
long, String, boolean, Date, Locale, List, Map, etc.

Loose Serialization del valore di ritorno
Model, List, Map, @JSON, JSONSerializable
http://www.liferay.com/community/wiki/-/wiki/Main/JSON+Serialization
Esempio
Numero di file nella Document Library suddivisi per «tipo»
(immagine, pdf, ecc.) e ultimo file modificato per ciascun tipo
Basic Authentication
Dati filtrati in base ai permessi dell’utente



http://localhost:8080/api/secure/jsonws/json-web-servicehook.dlstatistics/get-group-statistics?groupId=10180
http://issues.liferay.com/browse/LPS-27014
web.xml
<servlet>
<servlet-name>JSON Web Service Servlet</servlet-name>
<servlet-class>
com.liferay.portal.kernel.servlet.PortalClassLoaderServlet
</servlet-class>
<init-param>
<param-name>servlet-class</param-name>
<param-value>
com.liferay.portal.jsonwebservice.JSONWebServiceServlet
</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JSON Web Service Servlet</servlet-name>
<url-pattern>/api/jsonws/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>JSON Web Service Servlet</servlet-name>
<url-pattern>/api/secure/jsonws/*</url-pattern>
</servlet-mapping>
DLProcessor
Elaborazioni eseguite in modo asincrono al caricamento di un
file nella Document Library
Implementazioni dell’interfaccia
com.liferay.portlet.documentlibrary.util.DLProcessor

Proprietà dl.file.entry.processors
Esempio

hook

https://github.com/sergiogonzalez/image-geolocation-hook

Libreria esterna per leggere i dati Exif delle immagini
Latitudine e longitudine come Custom Field

Coordinate in una mappa nel portlet Document Library
liferay-hook.xml
<hook>
<portal-properties>portal.properties</portal-properties>
<custom-jsp-dir>/custom_jsps</custom-jsp-dir>
</hook>

portal.properties
application.startup.events=com.sympo.geolocation.AddImageGeoFieldsAction
dl.file.entry.processors=com.sympo.geolocation.ImageGeoLocationImpl
Sanitizer
«Disinfetta» i contenuti aggiunti dagli utenti
Commenti, blog, message board, wiki, calendario, ecc.

Eseguito prima del salvataggio nel database
Può modificare e adattare il contenuto
portlet-model-hints.xml
<field name="title" type="String">
<sanitize content-type="text/plain" modes="ALL" />
</field>
Esempio

hook

https://github.com/sergiogonzalez/mention-notifications-hook

Meccanismo per menzionare un utente del portale
@screename in un commento

Invio mail di notifica all’utente menzionato
liferay-hook.xml
<hook>
<portal-properties>portal.properties</portal-properties>
<custom-jsp-dir>/custom_jsps</custom-jsp-dir>
<service>
<service-type>
com.liferay.portlet.messageboards.service.MBMessageLocalService
</service-type>
<service-impl>
com.sympo.portlet.messageboards.service.MentionUsersMessageServiceImpl
</service-impl>
</service>
</hook>

portal.properties
application.startup.events=com.sympo.action.AddMentionedUsersFieldsAction
sanitizer.impl=com.sympo.sanitizer.MentionSanitizerImpl
AutoLogin
Ottenere un utente da una request non autenticata
Cookie, Header, sessione, ecc.

Integrazioni con sistemi SSO
Implementazioni dell’interfaccia
com.liferay.portal.security.auth.AutoLogin
Proprietà auto.login.hooks
https://github.com/sergiogonzalez/twitter-login-hook
Antivirus
Controllo file nella Document Library

Implementazione dell’interfaccia
com.liferay.portlet.documentlibrary.antivirus.AntivirusScanner
Proprietà dl.store.antivirus.impl

https://github.com/sergiogonzalez/eset-antivirus-hook
Grazie!

andrea.digiorgi@smc.it

Mais conteúdo relacionado

Semelhante a Using Plugins to extend and customize Liferay

Asp.Net MVC 3 - Il Model View Controller secondo Microsoft
Asp.Net MVC 3 - Il Model View Controller secondo MicrosoftAsp.Net MVC 3 - Il Model View Controller secondo Microsoft
Asp.Net MVC 3 - Il Model View Controller secondo MicrosoftStefano Benedetti
 
Asp.net 4 Community Tour VS2010
Asp.net 4 Community Tour VS2010Asp.net 4 Community Tour VS2010
Asp.net 4 Community Tour VS2010Fabrizio Bernabei
 
Sviluppare un plugin WordPress da zero - WordCamp Bologna 2018
Sviluppare un plugin WordPress da zero - WordCamp Bologna 2018Sviluppare un plugin WordPress da zero - WordCamp Bologna 2018
Sviluppare un plugin WordPress da zero - WordCamp Bologna 2018Marco Chiesi
 
Web Api – The HTTP Way
Web Api – The HTTP WayWeb Api – The HTTP Way
Web Api – The HTTP WayLuca Milan
 
Come portare il profiler di symfony2 in drupal8
Come portare il profiler di symfony2 in drupal8Come portare il profiler di symfony2 in drupal8
Come portare il profiler di symfony2 in drupal8Luca Lusso
 
ASP.NET MVC 6 - uno sguardo al futuro
ASP.NET MVC 6 - uno sguardo al futuroASP.NET MVC 6 - uno sguardo al futuro
ASP.NET MVC 6 - uno sguardo al futuroAndrea Dottor
 
Hands on MVC - Mastering the Web
Hands on MVC - Mastering the WebHands on MVC - Mastering the Web
Hands on MVC - Mastering the WebClaudio Gandelli
 
ASP.NET Core - dove siamo arrivati
ASP.NET Core - dove siamo arrivatiASP.NET Core - dove siamo arrivati
ASP.NET Core - dove siamo arrivatiAndrea Dottor
 
September 2010 - Gatein
September 2010 - GateinSeptember 2010 - Gatein
September 2010 - GateinJBug Italy
 
Creare API pubbliche, come evitare gli errori comuni
 Creare API pubbliche, come evitare gli errori comuni Creare API pubbliche, come evitare gli errori comuni
Creare API pubbliche, come evitare gli errori comuniAndrea Dottor
 
03 Tapestry5 In Action Introduzione
03   Tapestry5 In Action   Introduzione03   Tapestry5 In Action   Introduzione
03 Tapestry5 In Action Introduzionebobpuley
 
Creazione di una REST API in Liferay
Creazione di una REST API in LiferayCreazione di una REST API in Liferay
Creazione di una REST API in LiferayNunzio Mastrapasqua
 
Installing Apache tomcat with Netbeans
Installing Apache tomcat with NetbeansInstalling Apache tomcat with Netbeans
Installing Apache tomcat with NetbeansDavide Nardone
 
Struts - Overview, Installazione e Setup
Struts - Overview, Installazione e SetupStruts - Overview, Installazione e Setup
Struts - Overview, Installazione e SetupFederico Paparoni
 
Simone Carletti: Zend Framework ed i Web Service
Simone Carletti: Zend Framework ed i Web ServiceSimone Carletti: Zend Framework ed i Web Service
Simone Carletti: Zend Framework ed i Web ServiceFrancesco Fullone
 

Semelhante a Using Plugins to extend and customize Liferay (20)

Grasso Frameworks Ajax
Grasso Frameworks AjaxGrasso Frameworks Ajax
Grasso Frameworks Ajax
 
Asp.Net MVC 3 - Il Model View Controller secondo Microsoft
Asp.Net MVC 3 - Il Model View Controller secondo MicrosoftAsp.Net MVC 3 - Il Model View Controller secondo Microsoft
Asp.Net MVC 3 - Il Model View Controller secondo Microsoft
 
Asp.net 4 Community Tour VS2010
Asp.net 4 Community Tour VS2010Asp.net 4 Community Tour VS2010
Asp.net 4 Community Tour VS2010
 
Many Designs Elements
Many Designs ElementsMany Designs Elements
Many Designs Elements
 
Portlet JSR168/286
Portlet JSR168/286Portlet JSR168/286
Portlet JSR168/286
 
Sviluppare un plugin WordPress da zero - WordCamp Bologna 2018
Sviluppare un plugin WordPress da zero - WordCamp Bologna 2018Sviluppare un plugin WordPress da zero - WordCamp Bologna 2018
Sviluppare un plugin WordPress da zero - WordCamp Bologna 2018
 
Web Api – The HTTP Way
Web Api – The HTTP WayWeb Api – The HTTP Way
Web Api – The HTTP Way
 
Come portare il profiler di symfony2 in drupal8
Come portare il profiler di symfony2 in drupal8Come portare il profiler di symfony2 in drupal8
Come portare il profiler di symfony2 in drupal8
 
ASP.NET MVC 6 - uno sguardo al futuro
ASP.NET MVC 6 - uno sguardo al futuroASP.NET MVC 6 - uno sguardo al futuro
ASP.NET MVC 6 - uno sguardo al futuro
 
react-it.pdf
react-it.pdfreact-it.pdf
react-it.pdf
 
Hands on MVC - Mastering the Web
Hands on MVC - Mastering the WebHands on MVC - Mastering the Web
Hands on MVC - Mastering the Web
 
ASP.NET Core - dove siamo arrivati
ASP.NET Core - dove siamo arrivatiASP.NET Core - dove siamo arrivati
ASP.NET Core - dove siamo arrivati
 
September 2010 - Gatein
September 2010 - GateinSeptember 2010 - Gatein
September 2010 - Gatein
 
Creare API pubbliche, come evitare gli errori comuni
 Creare API pubbliche, come evitare gli errori comuni Creare API pubbliche, come evitare gli errori comuni
Creare API pubbliche, come evitare gli errori comuni
 
03 Tapestry5 In Action Introduzione
03   Tapestry5 In Action   Introduzione03   Tapestry5 In Action   Introduzione
03 Tapestry5 In Action Introduzione
 
Django
DjangoDjango
Django
 
Creazione di una REST API in Liferay
Creazione di una REST API in LiferayCreazione di una REST API in Liferay
Creazione di una REST API in Liferay
 
Installing Apache tomcat with Netbeans
Installing Apache tomcat with NetbeansInstalling Apache tomcat with Netbeans
Installing Apache tomcat with Netbeans
 
Struts - Overview, Installazione e Setup
Struts - Overview, Installazione e SetupStruts - Overview, Installazione e Setup
Struts - Overview, Installazione e Setup
 
Simone Carletti: Zend Framework ed i Web Service
Simone Carletti: Zend Framework ed i Web ServiceSimone Carletti: Zend Framework ed i Web Service
Simone Carletti: Zend Framework ed i Web Service
 

Using Plugins to extend and customize Liferay