Wednesday, 10 August 2016

Using Liferay Service Builder with liferay7


Using service Builder in Liferay 7-:

In liferay 7 we can create services using the liferay service builder as we used to do in the previous version of liferay.

First we need to create a new project with the template servicebuilder. Once you have filled the name of the project click on next and fill in the package name.


You will see that there are 3 projects created.
1) student-services
2) student-services-api-> will contain the Interfaces and the model classes.
3)student-services-service ->will contain the Impl classes

Open up the service.xml from the student-services-service project and enter the entities that you want to insert. Once you are done click on the buildService from the Gradel Tasks.
Once the services are created you can see that classes are generated in the *-services and the *-api projects.
Now we need to deploy this service in order to use this in some portlet. Deploy this by clicking on the deploy task in the Gradel Task. Once done you can see in the GOGO shell that *.service are installed. In this case that will be student.services.service
Now we will have to deploy generated services. So goto the Gradel Task of student-services and execute the deploy task.

This will generate the required JARs deploy and start them. You can verify the same in tomcat logs.
17:35:43,969 INFO  [fileinstall-F:/LR7/liferay-ce-portal-7.0-ga2/osgi/modules][BundleStartStopLogger:35] STARTED student.services-api_1.0.0 [489]
17:35:44,581 INFO  [fileinstall-F:/LR7/liferay-ce-portal-7.0-ga2/osgi/modules][BundleStartStopLogger:35] STARTED student.services-service_1.0.0 [490]

Our services are deployed and ready for use. Now we need to write a consumer, In this case it will be a new portlet. You can refer to my previous tutorials for process of how to create a new portlet.
Create a new portlet named Student-Portlet. Now we have to inform this portlet that it will needs to  consume the above generated services. To do that open the build.gradel file of Student-Portlet and give the dependency of the above services as follows.
compile  project(':modules:student-services:student-services-api')
compile  project(':modules:student-services:student-services-service')
If you are going to use these services now in your portlet you will be getting a compile time error. To remove those errors we will have to do a gradel refresh like this.
Once done you can use the services in your portlet.


http://liferaytutorials4u.blogspot.com/2016/08/how-to-create-and-deploy-portlet-in.html
http://liferaytutorials4u.blogspot.com/2016/08/how-to-create-liferay-workspace-using.html



Tuesday, 9 August 2016

Usefull Felix GOGO Command List

Usefull Felix GOGO Command List For LIFERAY 7 -:




lb: lists all of the bundles installed in Liferay’s module framework. Use the -s flag to list the bundles using the bundles’ symbolic names.

b [bundle ID]: lists information about a specific bundle including the bundle’s symbolic name, bundle ID, data root, registered (provided) and used services, imported and exported packages, and more
headers [bundle ID]: lists metadata about the bundle from the bundle’s MANIFEST.MF file

diag [bundle ID]: lists information about why the specified bundle is not working (e.g., unresolved dependencies, etc.) in short it is a debugging tool

packages [package name]: lists all of the named package’s dependencies.  This can be used to list all the bundles which use the given package.

scr:list: lists all of the components registered in the module framework. (scr stands for service component runtime.)
services: lists all of the services that have been registered in Liferay’s module framework.

install [path to JAR file]: installs the specified bundle into Liferay’s module framework. If path is not given it will try to deploy the bundle in the current directory

start [bundle ID]: starts the specified bundle

stop [bundle ID]: stops the specified bundle

uninstall [bundle ID]: uninstalls the specified bundle from Liferay’s module framework


Monday, 8 August 2016

Creating a Portlet with multiple action methods Using MVC Action Command

Creating a Portlet with multiple action methods Using Action Command -:
In the previous tutorial we had created a portlet and deployed it. It was a basic sample portlet. In this tutorial we are going one step forward and we will be looking into how we can associate the actions using the Liferay MVC Command classes.

Friday, 5 August 2016

How to create and deploy a portlet in liferay7 using liferay IDE and Gradel

New Portlet/Module Using Liferay IDE



To create anew portlet in liferay we first need to install the Blade CLI and then we need to create a new Liferay Workspace. Please go through the above tutorials if you haven't yet installed Blade CLI and created Liferay Workspace.

How to create a liferay Workspace using Liferay IDE

How to create a liferay Workspace using Liferay IDE

So What is liferay workspace, A liferay workspace project is a project that is intended to generate and hold up all of the  liferay module and projects. This helps out the developer by providing Gradel scripts and the configuration properties, so that the user is not suppose create and configure the properties required to develop and build the projects.
The Liferay workspace even had the support for legacy WAR based projects using the Plugins SDK. The developer can configure the workspace to develop the projects in the same way.

Before creating a workspace please go through the tutorial on how to install blade. Blade installation is required in order to use the Liferay Workspace.

So now How to create your first Liferay Workspace -:
Click on New -> Liferay Workspace Project
Enter the desired name in this case FirstWorkspace. Click on Finish. This will create a new Workspace.
If you want to configure the liferay server automatically and want to download liferay portal. click on the Download liferay bundle, this will download a new liferay bundle and will configure a new server with the downloaded bundle. This is one of the sample of power that liferay workspace provides to the user.


Once the liferay workspace is created it will generate a folder structure as shown below.


Following are the details of the folder structure created in the project.
Configs -> This folder holds the configuration files for different environments. For example in the above folder structure we can see that there are DEV, LOCAL, UAT and PROD environment. Each environment is having its own properties file. These files will be picked up depending upon the environment upon which the build is being deployed.  The current environment is controlled from the gradle.properties.
Gradel -> It holds the Gradel Wrappers that are used by the workspace
Modules-> It holds the custom modules that are being developed in this Liferay Workspace project .
Themes -> It holds the themes that has been generated by using the Theme Generator.
gradel.properties ->  This file contains the liferay and envirment specific properties that would be used by gradel to build up this module.  Folowing are some of the properties that are by default available to the gradel.
#liferay.workspace.bundle.url=https://sourceforge.net/projects/lportal/files/Liferay Portal/7.0.1 GA2/liferay-ce-portal-tomcat-7.0-ga2-20160610113014153.zip
#liferay.workspace.environment=local
#liferay.workspace.home.dir=bundles
#liferay.workspace.modules.default.repository.enabled=false
#liferay.workspace.modules.dir=modules
#liferay.workspace.plugins.sdk.dir=plugins-sdk
#liferay.workspace.themes.dir=themes


microsoft.translator.client.id=
microsoft.translator.client.secret=


One of the feature of using the liferay workspace project is that it will hide the complexities of gradel by adding multiple sub project in the setting.gradel file. you need not to worry about them.
In other case if you want to configure a pre existing Liferay server to the Liferay Workspace you need to specify the Liefray Home of the server in the gradel.properties.

liferay.workspace.home.dir=PATH_TO_LIFERAY_HOME

Once we are done with the development and want to share this workspace to someone else, we can go ahead and bundle the complete workspace into a single file using the following command -:
.\gradlew distBundle[Zip|Tar]
This will generate a Tar|Zip file and that can be distributed to the users.
gradlew initBundle
Is used to test the current build on the liferay instance. The liferay instance is taken
from the gradel.properties file as described above.

It’s important to note that an Eclipse workspace can only have one Liferay Workspace project.




For more details on the above topic please go through the below video on my youtube channel.      

Monday, 1 August 2016

Creating portlet in Liferay7 using blade - OSGI

How to Create and Deploy a new Portlet using Blade


To create modules using blade is quite simple. It is as good as creating the portlets using the command line tool of liferay SDK. To create the modules using the Blade you need to first install Blade. For knowing how to install blade please refer to my previous blog post on blade-installation-for-liferay7.  

Once you had installed blade on your machine, you need to navigate to the directory where you need to create the portlet.

To create a module/portlet using blade, following the minimal command

blade create [OPTIONS] <NAME>

blade create My-Sample-Portlet

The above command will create a new portlet with default configurations and a controller with the name MySamplePortlet.
blade create -t mvcportlet -p com.liferay.docs.mvcportlet.portlet -c MyMvcPortlet my-mvc-portlet-project
The above command will create a new project in the current with the name my-mvc-portlet-project. Because we are using the template mvcportlet this project will be created as a MVCPortlet Project, and the module will be having the Controller which will extend the MVCPortlet.java. The controller class will be in the package com.liferay.docs.mvcportlet.portlet and the name of the controller will be MyMvcPortlet.
Once the above command is punched in cmd, the below screen will come up. This will initially download the Gradel distribution as the build process will be using gradle.

Once completed the below screen will come up with a message that Create the project my-mvc-portlet-project using the mvcportlet template in <DIRECTORY>

Once created we can import the above project into eclipse using the import of eclipse. Click on Import->Liferay Module Projects
Click on the browse and provide the location of project.
Once imported the project will come up in the below shown structure. This verifies that the project has been created successfully.

Blade deploy
Now the next step is how to deploy the module/portlet into liferay. To do that it is easy, we just need to write the blade deploy command. This will search for the running instance of liferay on that machineand will deploy this module into the same.
blade deploy
blade deploy <PORT> - Will deploy in a liferay instance running on an specific port.
Below the image that shows that the Build is successfull and Portlet/module has been Started.
We can also see in the eclipse Console as shown below that the portlet/module is available for use. Here STARTED means available for use.

How to create portlet Using Blade in Liferay7

How to deploy portlet in Liferay7

Saturday, 30 July 2016

Blade installation for Liferay7

BLADE Installation for Liferay7

Blade is used to create the OSGI modules for liferay. Though liferay has provided the module support by the plugin SDK, but the modules created by blade can be used with any IDE or any other development environment. Blade is a command line tool that is used to create the modules for liferay 7.
The best and easiest way to install the blade is using the JAR file. This JAR can be installed using the JPM (JAVA PACKAGE MANAGER)
How to install Blade for Liferay7
  • Download the biz.aQute.jpm.run.jar JAR and save it in a directory. Let's say C:\Download
  • Now run the following command in command prompt c:\Downloads>java -jar biz.aQute.jpm.run.jar -g init
  • It will get install the JPM in C:\JPM4J
  • Now run this command. C:\JPM4J\bin> jpm platform path -a . This will add the jpm command in ENV-User Variable so that this can be used in commad prompt.
  • Now add the C:\JPM4J\bin in system variable PATH
  • Run the following command from C:\JPM4J\bin, so that the Blade can be installed, C:\JPM4J\bin>jpm install -f https://liferay-test-01.ci.cloudbees.com/job/liferay-blade-cli/lastSuccessfulBuild/artifact/com.liferay.blade.cli/generated/com.liferay.blade.cli.jar

  • Once the Blade is installed successfully you can verify the same by running the blade version command.



Blade provides a set of command line tools that can be used to create, update, deploy, start etc a module.
  • version-- Display Blade version.
  • create-- Creates a new Liferay module project from available templates.
  • deploy-- Builds and deploy the module for Liferay framework. It detects the current running liferay7 instance and deploy the module in the same.
  • gw-- Executes the Gradle commands using the Gradle Wrapper, if found, else it would not be executed.
  • init-- Initializes a new Liferay Workspace.
  • install-- Installs a bundle into Liferay’s module framework.
  • help-- Gives help on a specific command.
  • server-- Starts or stops server defined by your Liferay project.
  • open-- Opens or imports a file or project in Liferay IDE.
  • migrateTheme-- Migrates a Plugins SDK theme to a new workspace theme project, this is useful when you are migrating the themes.
  • samples-- Will create a sample project of Blade.
  • update-- Will update the Blade to current version of Blade

For more details on the above topic please go through the below video on my youtube channel

 

Copyright @ 2016 LiferayRevisited.