Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Daniel Cosmin
Audit Portlet
May 22, 2012 2:29 AM
Answer

Daniel Cosmin

Rank: New Member

Posts: 8

Join Date: May 7, 2012

Recent Posts

Hello,

Related to Auditing in Custom Portlet I would ask you to tell me how I can implement this feature because of the documentation I'm not so clear.
How will be store the data from the FORM in Database or Log files .
Exists some AuditLocalServiceUtil Class with method Save ?
Can you provide me the Sample Audit Portlet in order to analyse the code ?

Thank you in advance.

BR,
Daniel.
David H Nebinger
RE: Audit Portlet
May 23, 2012 7:58 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7238

Join Date: September 1, 2006

Recent Posts

The audit hook and portlet are both available from the EE plugins download page.

They are only available to EE customers.

If you are an EE customer, you can grab them. There's also a nice Wiki page describing how to use the AuditLocalServiceUtil class provided by the audit portlet: http://www.liferay.com/community/wiki/-/wiki/Main/Adding+Auditing+Functionality+to+Portlets
srini vasulu
RE: Audit Portlet
December 2, 2012 9:01 AM
Answer

srini vasulu

Rank: New Member

Posts: 14

Join Date: February 21, 2011

Recent Posts

Hi David,
I am trying to add audit to custom portlet i am facing below problem

i want to audit the custom portlet i added like below in portlet.properties file
value.object.listener.com.mcmcg.lawfirmportal.documenttype.model.DocumentBundleUserDetails=com.liferay.portal.audit.hook.listeners.DocumentBundleListener
if any one having idea how create the audit for custom portlet.
but i am getting the below error when i deploy my hook.

16:53:58,031 WARN [ClpSerializer:72] Unable to locate deployment context from portlet properties
java.lang.ExceptionInInitializerError
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.mcmcg.lawfirmportal.documenttype.service.ClpSerializer.getServletContextName(ClpSerializer.java:63)
at com.mcmcg.lawfirmportal.documenttype.service.messaging.ClpMessageListener.getServletContextName(ClpMessageListener.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.liferay.portal.kernel.deploy.hot.BaseHotDeployListener.getClpServletContextName(BaseHotDeployListener.java:61)
at com.liferay.portal.kernel.deploy.hot.BaseHotDeployListener.registerClpMessageListeners(BaseHotDeployListener.java:127)
at com.liferay.portal.deploy.hot.PluginPackageHotDeployListener.doInvokeDeploy(PluginPackageHotDeployListener.java:113)
at com.liferay.portal.deploy.hot.PluginPackageHotDeployListener.invokeDeploy(PluginPackageHotDeployListener.java:51)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._doFireDeployEvent(HotDeployUtil.java:111)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._fireDeployEvent(HotDeployUtil.java:188)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:40)
at com.liferay.portal.kernel.servlet.HookContextListener.contextInitialized(HookContextListener.java:36)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4205)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4704)
at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1282)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1380)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:306)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1385)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1649)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1658)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1638)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException
at com.liferay.portal.configuration.ConfigurationImpl.getFileName(ConfigurationImpl.java:500)
at com.liferay.portal.configuration.ConfigurationImpl.<init>(ConfigurationImpl.java:133)
at com.liferay.portal.configuration.ConfigurationImpl.<init>(ConfigurationImpl.java:64)
at com.liferay.portal.configuration.ConfigurationFactoryImpl.getConfiguration(ConfigurationFactoryImpl.java:28)
at com.liferay.portal.kernel.configuration.ConfigurationFactoryUtil.getConfiguration(ConfigurationFactoryUtil.java:25)
at com.liferay.util.portlet.PortletProps.<init>(PortletProps.java:65)
at com.liferay.util.portlet.PortletProps.<clinit>(PortletProps.java:69)
... 29 more
16:53:58,046 INFO [HookHotDeployListener:471] Registering hook for audit-hook
Loading file:/D:/devlopment/projects/Encore/liferay-portal-6.0-ee-sp2/tomcat-6.0.32/temp/4-audit-hook/WEB-INF/classes/portal.properties
16:53:58,343 ERROR [HotDeployUtil:114] com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering hook for audit-hook
com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering hook for audit-hook
at com.liferay.portal.kernel.deploy.hot.BaseHotDeployListener.throwHotDeployException(BaseHotDeployListener.java:46)
at com.liferay.portal.deploy.hot.HookHotDeployListener.invokeDeploy(HookHotDeployListener.java:271)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._doFireDeployEvent(HotDeployUtil.java:111)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._fireDeployEvent(HotDeployUtil.java:188)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:40)
at com.liferay.portal.kernel.servlet.HookContextListener.contextInitialized(HookContextListener.java:36)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4205)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4704)
at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1282)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1380)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:306)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1385)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1649)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1658)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1638)
at java.lang.Thread.run(Thread.java:619)
Caused by: com.liferay.portal.kernel.bean.BeanLocatorException: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'com.mcmcg.lawfirmportal.documenttype.service.persistence.DocumentBundleUserDetailsPersistence' is defined
at com.liferay.portal.bean.BeanLocatorImpl.locate(BeanLocatorImpl.java:71)
at com.liferay.portal.kernel.bean.PortalBeanLocatorUtil.locate(PortalBeanLocatorUtil.java:48)
at com.liferay.portal.deploy.hot.HookHotDeployListener.getPersistence(HookHotDeployListener.java:1097)
at com.liferay.portal.deploy.hot.HookHotDeployListener.initModelListener(HookHotDeployListener.java:1442)
at com.liferay.portal.deploy.hot.HookHotDeployListener.initModelListeners(HookHotDeployListener.java:1473)
at com.liferay.portal.deploy.hot.HookHotDeployListener.doInvokeDeploy(HookHotDeployListener.java:538)
at com.liferay.portal.deploy.hot.HookHotDeployListener.invokeDeploy(HookHotDeployListener.java:268)
... 15 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'com.mcmcg.lawfirmportal.documenttype.service.persistence.DocumentBundleUserDetailsPersistence' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1083)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:274)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1075)
at com.liferay.portal.bean.BeanLocatorImpl.doLocate(BeanLocatorImpl.java:113)
at com.liferay.portal.bean.BeanLocatorImpl.locate(BeanLocatorImpl.java:68)
... 21 more
David H Nebinger
RE: Audit Portlet
December 2, 2012 6:33 PM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7238

Join Date: September 1, 2006

Recent Posts

When adding a model listener on your own entities, you must do it in the project that provides the service, you cannot do it from an outside project.
srini vasulu
RE: Audit Portlet
December 3, 2012 5:19 AM
Answer

srini vasulu

Rank: New Member

Posts: 14

Join Date: February 21, 2011

Recent Posts

David H Nebinger:
When adding a model listener on your own entities, you must do it in the project that provides the service, you cannot do it from an outside project.


Hi David,

Thanks for you quick Reply, now i have added the code for audit in my custom portlet which provides the service.

We have created a listener class inside this we call the

AuditMessage auditMessage = AuditMessageBuilder.buildAuditMessage(eventType, DocumentBundleUserDetails.class.getName(), documentBundleUserDetails.getDocumentBundleId(),null);

AuditRouterUtil.route(auditMessage);

we have created a language properties and added the below details :-

model.resource.com.mcmcg.lawfirmportal.documenttype.model.DocumentBundleUserDetails = DocumentBundleUserDetails
action.com.mcmcg.lawfirmportal.audit.DocumentBundleListener = onBeforeCreate,onBeforeRemove

But the class is not getting invoked, please do let me know if we have missed any step.

I have added com.liferay.portal.servlet.filters.audit.AuditFilter=true this in portal-ext.properties file.

Regards
Srinu
srini vasulu
RE: Audit Portlet
December 3, 2012 5:20 AM
Answer

srini vasulu

Rank: New Member

Posts: 14

Join Date: February 21, 2011

Recent Posts

srini vasulu:
David H Nebinger:
When adding a model listener on your own entities, you must do it in the project that provides the service, you cannot do it from an outside project.


Hi David,

Thanks for you quick Reply, now i have added the code for audit in my custom portlet which provides the service.
We have created a listener class inside this we call the
AuditMessage auditMessage = AuditMessageBuilder.buildAuditMessage(eventType, DocumentBundleUserDetails.class.getName(), documentBundleUserDetails.getDocumentBundleId(),null);
AuditRouterUtil.route(auditMessage);
we have created a language properties and added the below details :-
model.resource.com.mcmcg.lawfirmportal.documenttype.model.DocumentBundleUserDetails = DocumentBundleUserDetails
action.com.mcmcg.lawfirmportal.audit.DocumentBundleListener = onBeforeCreate,onBeforeRemove
But the class is not getting invoked, please do let me know if we have missed any step.
I have added com.liferay.portal.servlet.filters.audit.AuditFilter=true this in portal-ext.properties file.
Regards
Srinu
David H Nebinger
RE: Audit Portlet
December 4, 2012 5:13 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7238

Join Date: September 1, 2006

Recent Posts

In your plugin that is providing the services, you need to add a hook.

In docroot/WEB-INF/src, add a portal.properties file with the line:

1value.object.listener.com.mcmcg.lawfirmportal.documenttype.model.DocumentBundleUserDetails=com.liferay.portal.audit.hook.listeners.DocumentBundleListener


You should also have the com.liferay.portal.audit.hook.listeners.DocumentBundleListener class in this project also.

in docroot/WEB-INF directory you'll also have your liferay-hook.xml file:

1<hook>
2    <portal-properties>portal.properties</portal-properties>
3    <language-properties>language.properties</language-properties>
4</hook>


The missing portal.properties addition would explain why your model listener is not getting called.

I don't know what you think the "action.com.mcmcg..." line is supposed to be doing, but since it is in the language.properties file it won't be doing what you think...