Laliwala IT Services

Laliwala IT Services
Website Development

Sunday, February 20, 2011

(resolved) addFolder(...) is not being called from EXT. - please help.



























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Sam w :

(resolved) addFolder(...) is not being called from EXT. - please help.








I have added more System.out.printlns in the addFolder method in IGFolderServiceImpl and have recomplied portal-impl. By running the ImageGallery portlet, observed the printlns are printed out by adding new folder in the portlet - that is fine. But when I use





IGFolderServiceUtil.addFolder(parentFolderId, name, description, serviceContext);





in the EXT enviornment in my own portlet, the addFolder method is not being executed. The execution of addFolder(...) is stopped when the Action class reached the above method.





This is a very unusual error, I never seen an Action class finished half way without any error/exception.





I am looking forward to any suggestion and help.





Thanks


Sam



Sam w : That raises another question, do I have to recreate the service of imagegallery in the EXT environment before I can use its methods from EXT?





Thanks


Sam



Sam w : Or do I have to include imagegallery portlet in EXT porperties xml files so that my portlet can use its methods (APIs) from EXT?





Sam



Babu Janarthanan : hi,


i guess it is failing over the permissions.





IGFolderPermission.check(


getPermissionChecker(), serviceContext.getScopeGroupId(),


parentFolderId, ActionKeys.ADD_FOLDER);


cross check the permission or try to add try..catch block in IGFolderServiceImpl and give printStackTrace().





hope it helps you...





Thx,


Babu



Sam w : Hi Babu,





Thank you for your quick reply.





I created a class (IGFolderLocalServiceExtImpl) extends from IGFolderServiceImpl class for overwriting the method addFolder(..) with the removal of the IGFolderPermission.check(..).










In my Action class, how to invoke the IGFolderLocalServiceExtImpl class and addFolder() method?





I remembered I should build a ServiceUtil class, but I forgot how to "instruct" service.xml to build automatically.





Thanks


Sam.






Mazhar Anwar : Hi Sam,





You don't to build service again. You can use same Util classes and other Implementation by using ext-spring.xml.





Please find the portal-sprint.xml in portal-impl/src/META-INF folder and search for Impl Class you wanna to modify.





for example, for IGFolderLocalServiceImpl.java you can see this entry





"<bean id="com.liferay.portlet.imagegallery.service.IGFolderLocalService.impl"





class="com.liferay.portlet.imagegallery.service.impl.IGFolderLocalServiceImpl" />"





Now open the ext-spring.xml which is in ext-impl/src/META-INF folder and add a new entry

<bean id="com.liferay.portlet.imagegallery.service.IGFolderLocalService.impl" class="com.ext.portlet.imagegallery.service.impl.IGFolderExtLocalServiceImpl" />





where IGFolderExtLocalServiceImpl is your implementation java class name.





Note : This is not a standard process but it is easy and you can use for RnD purpose. Actual implementation should be using plugins-hooks emoticon





Regards,



Sam w : I think I need to go for plugins.





Thank you for the answer.





Sam.



Sam w : I followed the following plugin wiki and created liferay-hook.xml and IGFolderLocalServiceWrapperImpl.java.





http://www.liferay.com/community/wiki/-/wiki/Main/Wrapper+Plugins





I didn't change anything else.





After "deploy" and started up liferay, the following code still not calling my WrapperImpl class.





IGFolderServiceUtil.addFolder(parentFolderId, name, description, serviceContext);





How to use my own wrapper class after the liferay-hook.xml is created.





Thanks


Sam



Sam w : Hi,





After created the following liferay-hook.xml file and the WrapperImpl class, how to build and use them?










Thanks


Sam.



Mazhar Anwar
Hi Sam,





ServiceImpl with plugins is available with Liferay6 only as ServiceWrapper classes are not in Liferay5.2.x. So I think for older version, we can use the previous approach.



Sam w : Hi Mazhar,





Thank you for the link, very useful indeed.





If only want to overwrite IGFloderLocalServiceImpl, can I use this approach?





BTW, is liferay 6.0 released yet? or is it still in RC stage?





Thanks


Sam



Mazhar Anwar : Hi Sam,





If it is urgent as of now, I would suggest you to follow the ext approach what is there in previous post above. Liferay 6.0.1 has been released but still it has many issues and it seems we dont have any stable version for Liferay6.





Regards,



Sam w : Hi Mazhar,





Do you meant use the ext-spring approach as you mentioned preiovusly?





After I have added the following bean in the ext-spring.xml file and deployed, then start liferay, there are many errors about bean is not found..





eg.


..


..





Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.liferay.portal.kernel.scheduler.SchedulerEngine'





..





Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.liferay.portal.service.QuartzLocalService.impl'





..





Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.liferay.portal.service.AccountLocalService.impl'





Here is what I have added into the ext-spring.xml file:





<bean id="com.liferay.portlet.imagegallery.service.IGFolderLocalService.impl" class="au.com.ip6.ext.portlet.myext.impl.IP6IGFolderLocalServiceWrapperImpl" />





Very appreciate for your reply.





Thanks


Sam



Sam w : The error shown on the console is:










I don't understand why it must use the format 'com.liferay.portlet.imagegallery.service.IGFolderLocalService.impl' in ext-spring,





Shouldn't it 'com.liferay.portlet.imagegallery.service.IGFolderLocalServiceImpl'?





Thanks


Sam



Sam w : Here are more errors:










My ext-spring.xml is:










Very appreciate for any further suggestion and help





Thanks


Sam



Sam w : Hi Babu,





I avoided creating plugin/ext and directly changed the addFolder(..) method in the IGFolderServiceImpl class, by commented out the IGFolderPermission.check, and also added a System.out.println as soon as the called is entered into the addFolder method in IGFolderServiceImpl class. After restarted liferay, I still can't see the addFolder method in the IGFolderServiceImpl class is being called.





Here is the IGFolderLocalServiceImpl class:










Acton class:










The System.out.prinln after addFolder method is never get called, and also the System.out.prinln inside the addFolder is never shown in the console when it is calling from EXT environment.





If I use ImageGallery portlet create a folder, the System.out.println inside the addFolder method in the IGFolderLocalServiceImpl class is get printed - getting called from ImageGallery portlet.





What is going on here?





I would very appreciate for further help and suggestion.





Thanks


Sam.



Babu Janarthanan : Hi


i suggest you to place try catch in your action class.





Acton class:










and pleas post the log. and give a try using IGFolderLocalServiceUtil.addFolder.





Thx,


Babu



Zen J : hi Sam,





if you dont mind can you share, how you have solved your issue. i have to implement same for Document Library.





Thx



Sam w : Hi Zen





In Action class, I have to use IGFolderLocalServiceUtil, and create your own class extends IGFolderLocalServiceBaseImpl.





then add a line in ext-spring.xml, or you may create your own myext-spring.xml with the same code as stated previously in this post.





Cheers


Sam









No comments:

Post a Comment