04 June 2019

Converting portlets from 6.2 to 7.1 requires us to know where code and configurations belong in both versions. They are more similar than they are dissimilar. Knowing the differences and how to upgrade 6.2 portlets is key. I say we are “upgrading” rather than “converting” because that is how Liferay views it. You will be required to create upgrade code to modify 6.2 configuration data to 7.1 configuration data. We will be converting a portlet with a service layer.

Lets first look at the differences in the Maven modules between the versions.

Maven Modules

7.1 Modules                       |  6.2 Modules
----------------------------------|-------------------------------------
modules                           | 
├── AllFeeds-Service              |  allFeeds                       
│   ├── AllFeeds-Service-api      |  ├── allFeeds-portlet        
│   ├── AllFeeds-Service-service  |  ├── allFeeds-portlet-service
├── AllFeeds-Web                  |  

We are converting a 6.2 portlet with an associated service layer. Our JSPs, CSS, JS, HTML and MVCPortlet based class would be in the allFeeds-portlet module. The code and configuration in allFeeds-portlet module will be moved/converted into the AllFeed-Web module. One exception is the service.xml. Strangely, in 6.2, our entity/table definitions would be located in allFeeds/allFeeds-portlet/src/main/webapp/WEB-INF/service.xml. This is now more naturally located in modules/AllFeeds-Service/AllFeeds-Service-service/service.xml. The file that defines our entities is located in the service module.

Additionally all the generated code from ServiceBuilder that used to appear in allFeeds-portlet and allFeeds-portlet-service now appears in AllFeeds-Service-api and AllFeeds-Service-service. The api AllFeeds-Service-api contains the public interfaces that are shared with other OSGI modules in Liferay. AllFeeds-Service-service contains the impl files that developers can customize. The same kind of impl files that used to be in allFeeds-portlet in 6.2. Additionally the service.properties file has also moved to AllFeeds-Service-service.

Service impl files in 6.2

allFeeds-portlet
├── pom.xml
└── src
    ├── main
    │   ├── java
    │   │   └── mil
    │   │       └── army
    │   │           └── hrc
    │   │               └── ikrome
    │   │                   └── feeds
    │   │                       ├── AllFeedsPortlet.java
    │   │                       ├── service
    │   │                       │   ├── model
    │   │                       │   └── service
    │   │                       │       ├── base
    │   │                       │       ├── impl
    │   │                       │       │   ├── LocationLocalServiceImpl.java
    │   │                       │       │   └── NewsfeedLocalServiceImpl.java
    │   │                       │       └── persistence
    │   │                       ├── upgrade
    │   │                       └── util
    │   ├── resources
    │   │   ├── META-INF
    │   │   ├── portal.properties
    │   │   ├── portlet.properties
    │   │   └── service.properties
    │   └── webapp
    └── test

Service Impl files in 7.1

AllFeeds-Service-service
├── bnd.bnd
├── pom.xml
├── service.xml
├── src
│   └── main
│       ├── java
│       │   └── mil
│       │       └── army
│       │           └── usaac
│       │               └── ikrome
│       │                   └── allfeeds
│       │                       └── service
│       │                           ├── activator
│       │                           ├── model
│       │                           ├── service
│       │                           │   ├── base
│       │                           │   ├── impl
│       │                           │   │   ├── LocationLocalServiceImpl.java
│       │                           │   │   └── NewsfeedLocalServiceImpl.java
│       │                           │   └── persistence
│       │                           ├── upgrade
│       │                           └── util
│       └── resources
│           ├── META-INF
│           └── service.properties
└── test                 

Most (all?) of the information previously contained in the portlet.xml and liferay-portlet.xml are now annotations to the portlet class in 7.1.


Less Is More ~ Older posts are available in the archive.