liferay,aop , How can I configure AOP in Liferay Service Builder?

How can I configure AOP in Liferay Service Builder?


Tag: liferay,aop

I want to to intercept a method in Service Builder, for example: XXXLocalService.update(). But I don't know the correct way to do this. I have done some research but I haven't found a clear way to do this.

Any help will be greatly appreciated.


There are basically two ways to achieve this in Liferay, assuming you want to intercept Liferay's services:

  1. Service Wrapper Hooks

    What this does is gives you a wrapper around the desired service, for eg: UserLocalServiceWrapper would be a wrapper around UserLocalService and would have complete control over the methods defined in this interface. And this is a good approach if you know the exact method you want to modify/intercept in that particular service.

    Also with this approach you have full control whether the original method should run or not.

    The link provides the full detailed tutorial how to achieve this.

  2. Model Listener Hooks

    This hook should be used when you want to track any changes on the particular Model like in the above case User and this is helpful when you are not sure which method is going to update the model.

    What this basically does is gives you a set of methods like onBeforeUpdate, onAfterUpdate, onAfterCreate etc to have control over the model.

    Also this approach would work good enough for your custom services as well.


Identify that the logged in user is an administrator or not using velocity

I would like to identify that the logged in user is an administrator or not using velocity. The goal is to show the dockbar to the administrator user(s) only. I have tried following code, but is not working for me: #if ($is_signed_in && $permissionChecker.isGroupAdmin($group_id)) #dockbar() #end Please help me!!!...

How to delete a portlet in Liferay 6.1 programmatically from code

I'm working on Liferay 6.1 I want to delete a portlet in Liferay 6.1 from my code. What I have done so far is: <a onclick="Liferay.Portlet.close('#p_p_id_28_'); return false;">Remove</a> Above code is working fine. But it is working on the current page only i.e. it can delete the portlet(s) which is...

how to bypass the necessity of having to have email address firstname and lastname in liferay to import authenticating users

My application uses liferay to connect to LDAP server and import authenticating users. But many of the user records in the ldap schema doesn't have email id. This seems to be preventing me from importing these users as liferay requires email id, among other things, inorder to successfully import new...

How to check for real liferay user after altering the request through Burpsuite

I'm doing some vulnerability check on Liferay by using Burpsuite. Through burpsuite, i changed the Get: request and the cookie Cookie: JSESSIONID=8415D05C1E66F72CE8803607B6FEC26B.node1; COOKIE_SUPPORT=true; USER_UUID="2n3duSU0cr8TgknmHzm8ghmRUS2LVJfx6zmuvGFspuY="; GUEST_LANGUAGE_ID=en_US; LFR_SESSION_STATE_2983586=1431672874448; COMPANY_ID=10154; ID=79307664464f436b414f657133626843444f577a65773d3d; from one user to another. The page then loads as if the user is the other user which i copied the request...

Portlet event send array of objects

We have multiple projects with multiple portlets and need to send an array of objects between them. Our situation: One of the porlets is like a "Master-portlet", it will be responsible for all the REST-calls and consume json-data and parse it to Java-Objects. All the other portlets will receive an...

How can I configure AOP in Liferay Service Builder?

I want to to intercept a method in Service Builder, for example: XXXLocalService.update(). But I don't know the correct way to do this. I have done some research but I haven't found a clear way to do this. Any help will be greatly appreciated....

How to pass HTTP request to Web-Service

From my portlet JSP, I am trying to make a Ajax call to web-service. My aim is to pass HTTP request object as a parameter to web-service method. Please suggest.

Does'nt Liferay work at different ports?

I have developed a portal page using Liferay and the port number is 8080. I wanted to test SSO, I decided not to try with the existing one as there might be some problems and I might end up crashing the whole thing. As a result I downloaded a new...

pointcut execution for specific class constructor

I'm trying to create specific class constructor pointcut execution but I get the following marker: Aspect code: public aspect CarLogger { private Logger logger; pointcut instantiate() : execution (; after() : instantiate(){ logger.log(Level.INFO, "In Car::Car()", thisJoinPoint.getThis()); } this code returns no match for this type name Car. But if I...

AOP pointcut expression for specific annotated variable

I have a scenario like this.. A custom annotation definition... @Target({ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) public @interface CacheMe{ String node(); } User details class... class User { String name; String ssn; } And a class with "User" object as variable and uses @CacheMe annotation Class Test{ @CacheMe(node="user") User user; public User getUser(Long id){...

Spring AOP use AspectJ to works or what?

I am studying Spring AOP and I have the following doubt. From what I know there are 2 ways to implement AOP behavior into a Java application that are: AspectJ: that is the first original AOP technology that uses byte code modification for aspect weaving. Spring AOP: Java-based AOP framework...

Customizing liferay Calendar portlet

I'm trying to customize Calendar portlet using this below instructions. Its basically creating Plugins to extend plugins. In order to achieve above, I need "Calendar-portlet.war" . I don't find any war file for calendar portlet for my version. So i decided to build myself. Then i downloaded Portal plugins...

AOP (without Spring) not working on Tomcat but Eclipse

Implemented AOP using AspectJ without Spring. It works perfectly fine when running in Eclipse (Tomcat server) but not when run directly in Tomcat. Have added required dependencies in the pom but of no use. Not able to figure out the issue. Aspect class: @Aspect public class FeatureAOP { private static...

Cons of a liferay cms while website development using Community Edition

I am new to LIFERAY CMS. i need cons of a liferay cms i.e., difficulties faced while developing and using liferay cms. can you please list cons of liferay cms.

Liferay database table work flow?

I am new to Liferay. Now I need to create the flow chart which has the Liferay table work flow in following scenarios, 1) What are the list of table will reflect/update if we create the site admin? 2) What are the list of table will reflect/update if we create...

How to ignore Liferay user removed from LDAP errors?

I have a Liferay 6.1 instance that is connected to LDAP. New users get imported nicely, but when I remove a user from the LDAP directory, Liferay starts throwing exceptions when it tries to sync users from LDAP. These seem to be safe to ignore, but they produce several megabytes...

How to add a custom section to the User Edit Screen in Liferay?

I want to customize the User-Edit page in Liferay 6.2. First of all I wanted to add a new section to the bar on the right of the user edit screen ( I have realized this with properties like users.form.add.main=customportlet When i click on the new created section it opens...

In liferay market place, I am unable to submit the project

In Liferay market place i am stuck at the place "Upload Liferay Plugin Packages " When ever i am trying to upload a war file Please help me to short it out :)...

How to host a newportal instance in liferay

I have created a new portal instance in liferay. I want to host it in my local Ubuntu machine. What i have done is created a WEB ID as Virtual host as and the mail domain as thanks...

Intercept Exceptions for logging with CDI's AOP on Java EE 7

I have the following class snippet, from which I'd like to remove the repetitive logging code and move it to an Interceptor using CDI's AOP. /** * Javadoc omitted */ public abstract class JpaDao<T extends LongIdentifiable> implements GenericDao<T> { @Override @Transactional public Long persist(T type) throws GeneralPersistenceException { if (type...

How to pass data from page to Portlet class through AJAX call?

I'm trying to pass a value in an AJAX 'GET' request to my Portlet class, but I can't quite figure out a way to access such variable's value in the class. My AJAX code is: function loadXMLDoc() { var nocache = new Date().getTime(); var xmlhttp=new XMLHttpRequest(); var url = "${mURL}";...

Incorrect liferay-plugins dependency

In following dependency is defined: dependencies { classpath group: "com.liferay.portal", name: "portal-service", version: "7.0.0-SNAPSHOT" } How can a 6.2.x version have a dependency on 7.0.0 version? Is it a bug? When I peek to the history of the file, the dependency has always been there. I am not able...

Register multiple EventHandlers for one portlet

I would like to register more than one EventHandler in a Portlet in my portlet.xml. Right now it looks like this: When trying to add a second block of init-param i get an error: Than i tryed to add multiple EventHandler in one init-param block, but i get this error:...

How can I change the zIndex attribute of aui-datepicker in Liferay Portlet 6.2

I have discoveder one problem with date field in portlet in LF 6.2. The problem is that after clicking on the input field, the datepicker is displaying, but with zIndex=0, that means it is under the portlet. If I change on firebug that parameter to 1, everything is OK. I...

Lifefay freemarker ADT: methods unavailable?

I'm trying to work on some ADT for asset publisher (Documents and Media type), but I often have a message telling me that : Expression assetRenderer.getDataRepositoryId is undefined or Expression assetRenderer.getFileEntryId is undefined I found some threads where people said that we must add velocity.engine.restricted.classes= velocity.engine.restricted.variables= freemarker.engine.restricted.classes= freemarker.engine.restricted.variables= in

I am working on a MVC Portlet and the document i am saving is not going to db

Here is my Action Class, where I have to save any document to database but its not working and getting error in console that NoSuchMethodException (javax.portlet.ActionRequest, javax.portlet.ActionResponse) package com.test.docupload; import; import; import; import; import javax.portlet.ResourceRequest; import javax.portlet.ResourceResponse; import javax.portlet.PortletException; import com.liferay.counter.service.CounterLocalServiceUtil; import...

Create Spring @Service instance with @Transactional methods manually from Java

Let's say there are @Service and @Repository interfaces like the following: @Repository public interface OrderDao extends JpaRepository<Order, Integer> { } public interface OrderService { void saveOrder(Order order); } @Service public class OrderServiceImpl implements OrderService { @Autowired private OrderDao orderDao; @Override @Transactional public void saveOrder(Order order) {; } } This...

Form submit portlet with Spring MVC

I'm trying to achieve a Liferay portlet of submit form using spring MVC. The model: package com.model; public class Person { String firstName; String middleName; public String getFirstName() { return this.firstName; } public String getMiddleName() { return this.middleName; } public void setFirstName(String firstName) { this.firstName=firstName; } public void setMiddleName(String middleName)...

Service builder doesn't delete table in DB

Hi all, I'm using LR 6.1. I created a new entity Called " Recommendation" in service.xml then a run BuildServices with Ant to generate the service builder Files. Now I want to delete the Entity. So I Deleted if from service.xml, but nothing happens in Data base and the other...

Customizing My Sites portlet in Liferay

I want to customize My Sites portlet (which is out of box portlet) in liferay using ext. How do I do this? How do I get the source code for the my sites portlet?

Customize CreateAccountAction in Liferay Portal

I'm trying to add "User Group" Selection field while creating a user (Self User Registration form - create_account.jsp). Here Custom fields is not helpful because Usergroup is already exists in db. I want to insert into existing Users_UserGroups table. I'm using below hook: But User is not added in the...

Users in Guest role see default theme instead custom one for given layouts

Users in Guest role see default theme instead custom one for pages which inherit from defined custom theme. This seems to be very strange problem. Even though layouts have specified to inherit theme from parent theme: Use the same look and feel of the Public Pages. Guests see them as...

Get list of users in liferay

I want to display users list on liferay. and I am having problem with it. Here is my action class. public void userList(ActionRequest actionRequest, ActionResponse actionResponse) throws SystemException { // Todo Logic for user code try { int countUser = UserLocalServiceUtil.getUsersCount();"User Present In DB" + countUser); List < User...

Liferay Maven Service Builder Portlet(Developer Studio)

I am new in Liferay platform. I am trying to implement CRUD in Liferay using portlet. I am using liferay 6.2 and IDE as a developer studio. I am creating project with below values (In Image) in developer studio. When I am creating project in Developer studio I am getting...

Include ftl file in ext plugin

I have ext-plugin and I would like to override this file: portal-impl\src\com\liferay\portlet\dynamicdatamapping\dependencies\ddm\documentlibrary.ftl. After maven build, this file isn't include in my porta-impl-ext.jar. In my portal-impl-ext's pom.xml I have this code: <build> <plugins> <plugin> <groupId>com.liferay.maven.plugins</groupId> <artifactId>liferay-maven-plugin</artifactId> <version>${liferay.maven.plugin.version}</version> <configuration>...

How manage styles in Vaadin portlet in Liferay

I have a Portlet, where is used Valo theme. Most graphical components are displayed properly, but TextField not. It should have rounded border radius and height should be about 35px. It has normally about 15px and the field is angular. When I narrow width of browser window to about 200px...

How do I access parameters specified in a Java Aspect?

I have an annotation called "@ProgressCheck" that we can put on a controller to check the progress of an application. If the application is already submitted or late, then it throws the user to a page appropriate for that situation. The annotation interface is: @Retention(RetentionPolicy.RUNTIME) public @interface ProgressCheck { }...

Liferay workflow Flow(ie:Kaleo WorkFlow)

I have a requirement.We have a form where we create users in liferay and it should go through approval process(ie:single approver).If the omni admin fills that form then the user must not go through approval process and when the same form is accessed by any other user it must go...

how to show values associate with a custom document in liferay 6.2

I created a document type, and I'm using Asset Publisher to display this types of documents I would like view the values that I associated with my custom document, that I created with the document library. What is the way to do this with velocity? I found this java code...

How to create service builder for liferay plugin project with maven

I have Already create Liferay Plugin project. and maven install also over. it gives ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] --------------------------------------------------------------------- [INFO] Total time: 1:29.773s [INFO] Finished at: Wed Jun 17 15:46:10 IST 2015 [INFO] Final Memory: 34M/151M [INFO] -----------------------------. But unable to add service builder. When i try to add...

Keep liferay-ui:search-container while paging

I have a <liferay-ui:search-container> displaying my results. I enabled a rowChecker, so that each row becomes selectable by a check box. It is placed in a form; in this way users can select more rows, then click on my "submit" button and the action is able to get ids of...

Difference between Liferay Mobile SDK and Liferay Screens

Can someone tell me the difference between Liferay Mobile SDK and Liferay Screens? Thanks a lot....

Liferay Migrating User from legacy database & LDAP

I am migrating data into Liferay from legacy database for which I have written script to programmatically push data into Liferay's user as I see fit. Now authentication happens with LDAP and some basic details of user are also in LDAP which is supposed to be synced. Will it cause...

Text internationalization in Javascript using liferay-ui:message

How can I do internationalization for this : alert('<liferay-ui:message key="please-choose-file-type" />'); Notice that I want to internationalize the message inside Alert using Liferay:ui:message tag. Thanks....

commandButton action method not invoked in Liferay

I've the below portlet view.xhtml: <?xml version="1.0"?> <f:view xmlns="" xmlns:c="" xmlns:f="" xmlns:h="" xmlns:ui="" xmlns:p=""> <h:body> <h:form> <h:commandButton value="TESTButton" action="#{navigationViewBean.submit}" /> <h:outputText value="TESTGetter: #{navigationViewBean.testField}" /> </h:form>...

AJAX Call not working in liferay 6.2.2?

I am trying to perform a AJAX Call. But what i get is ResourceURL as undefined when i see the error in chrome. Below is my code. Declaration: <liferay-portlet:resourceURL copyCurrentRenderParameters="<%= false %>" var="mainURL" /> Implementation:"POST", resourceURL , false); But at implmentation i get resourceURL as undefined. In 6.1 it...

Spring Boot Logger Aspects

I'm having problems getting my logging aspect to log information when methods from classes of a particular package are accessed. In other words, "no" logging occurs. I even got desperate and added System.out.println statements, with no luck. All of my classes are located under the package, i.e.,,...

How to upload file in relative directory

I have made a application where we can upload any file which will save in our local given directory. I want to modify it, i want to add a drop down (with multiple option i.e floor, store, section) for department. i.e if we want to upload a file in 'Store'...

Liferay Table Column Description

I am trying to understand the field level description for each table in life ray which are related to user management. I did not understand the purpose of some columns in the following tables. USER_: GRACELOGINCOUNT FACEBOOKID PORTRAITID GROUP_: PARENTGROUPID LIVEGROUPID TREEPATH TYPE_ TYPESETTINGS REMOTESTAGINGGROUPCOUNT ADDRESS: TYPEID PRIMARY_ PHONE: TYPEID...