Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Aldi Tirane
Setting Organization Site Public and Private pages programatically
February 13, 2013 2:42 AM
Answer

Aldi Tirane

Rank: Junior Member

Posts: 25

Join Date: October 23, 2012

Recent Posts

Hello,

i want to set programatically organization site public pages. I developed a new portlet and defined a new method inside the class that extends MVCPortlet.

Inside that method i defined the code that should do the assignement of 'publicLayoutSetPrototypeId' and 'privateLayoutSetPrototypeId'.

1MethodKey key = new MethodKey("com.liferay.portlet.sites.util.SitesUtil", "applyLayoutSetPrototypes",
2                            Group.class, long.class, long.class, ServiceContext.class );
3                   
4PortalClassInvoker.invoke(true, key, newOrg.getGroup(), 12008, 12008, context);

But the execution of the above code raises an exception:

1java.lang.NoSuchMethodException: com.liferay.portlet.sites.util.SitesUtil.applyLayoutSetPrototypes(com.liferay.portal.model.Group, long, long, com.liferay.portal.service.ServiceContext)
2    at java.lang.Class.getMethod(Class.java:1605)
3    at com.liferay.portal.kernel.util.MethodCache._get(MethodCache.java:123)
4    at com.liferay.portal.kernel.util.MethodCache.get(MethodCache.java:51)
5    at com.liferay.portal.kernel.util.MethodHandler.invoke(MethodHandler.java:63)
6    at com.liferay.portal.kernel.util.PortalClassInvoker.invoke(PortalClassInvoker.java:42)
7    at com.procedureKrijimitOrganizatave.KrijimiOrganizatavePortlet.procedureKrijimitTeOrganizatave(KrijimiOrganizatavePortlet.java:121)
8    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

Can anyone explain this situation?

Thanks.
Jan Geißler
RE: Setting Organization Site Public and Private pages programatically
February 13, 2013 4:05 AM
Answer

Jan Geißler

Community Moderator

Rank: Liferay Master

Posts: 735

Join Date: July 5, 2011

Recent Posts

The stack clearly states, that you are trying to invoke a method via reflection which does not exist.
Meera Prince
RE: Setting Organization Site Public and Private pages programatically
February 13, 2013 5:29 AM
Answer

Meera Prince

Rank: Liferay Legend

Posts: 1110

Join Date: February 8, 2011

Recent Posts

HI

Use LocalServiceUtil classes those are directly available in global class path instead of reflection calling.



Regards,
Meera Prince
http://www.liferaysavvy.com/
Aldi Tirane
RE: Setting Organization Site Public and Private pages programatically
March 7, 2013 1:33 AM
Answer

Aldi Tirane

Rank: Junior Member

Posts: 25

Join Date: October 23, 2012

Recent Posts

Here is my solution for who is interested.

Create class SiteUtil into your portlet and copy "com.liferay.portlet.sites.util.SitesUtil". Remove all methods not needed and remove errors. Then call the method "applyLayoutSetPrototypes(com.liferay.portal.model.Group, long, long, com.liferay.portal.service.ServiceContext)".

Hope it helps. Aldi