Fórum
Administer Portal programmatically
Sascha Handke, modificado 13 Anos atrás.
Administer Portal programmatically
New Member Postagens: 2 Data de Entrada: 06/01/11 Postagens Recentes
Hi,
we currently have the challange to administer a Liferay Portal programmatically. That means that pages are defined outside of Liferay and some kind of application is used to create pages within Liferay and add portlets (already existing in the Portal) to these pages. Is there some kind of API/WebService which could be used by an application to administer the portal programmatically? Right now I am a little lost because I can't find any information.
Any help is very well appreciated.
Yours
Sascha
we currently have the challange to administer a Liferay Portal programmatically. That means that pages are defined outside of Liferay and some kind of application is used to create pages within Liferay and add portlets (already existing in the Portal) to these pages. Is there some kind of API/WebService which could be used by an application to administer the portal programmatically? Right now I am a little lost because I can't find any information.
Any help is very well appreciated.
Yours
Sascha
Krishna Melkote, modificado 13 Anos atrás.
RE: Administer Portal programmatically
Junior Member Postagens: 52 Data de Entrada: 22/09/10 Postagens Recentes
I don't understand your requirement completely but have you looked at LAR (liferay archive)?
This is pretty powerful and flexible with import export capabilities via API.
Cheers
This is pretty powerful and flexible with import export capabilities via API.
Cheers
Milen Dyankov, modificado 13 Anos atrás.
RE: Administer Portal programmatically
Regular Member Postagens: 171 Data de Entrada: 23/09/09 Postagens Recentes
Have a look at what web services Liferay offers by visiting http://127.0.0.1:8080/tunnel-web/axis (assuming you run on port 8080 on localhost). Particularly Portal_LayoutService may be what you are looking for.
Liferay also provides portal-client.jar which may make your life easier if your external application is written in Java. There is sample portlet sample-portal-client-portlet demonstrating the use of portal-client.jar. You can download it or look at the code online: http://svn.liferay.com/browse/plugins/branches/6.0.x/portlets/sample-portal-client-portlet/docroot/view.jsp?r=HEAD. Since this is Liferay portlet the dependeant libraries are in liferay-plugin-package.properties ( http://svn.liferay.com/browse/plugins/branches/6.0.x/portlets/sample-portal-client-portlet/docroot/WEB-INF/liferay-plugin-package.properties?r=HEAD). Make sure co place them on your application's classpath.
Hope this helps.
Liferay also provides portal-client.jar which may make your life easier if your external application is written in Java. There is sample portlet sample-portal-client-portlet demonstrating the use of portal-client.jar. You can download it or look at the code online: http://svn.liferay.com/browse/plugins/branches/6.0.x/portlets/sample-portal-client-portlet/docroot/view.jsp?r=HEAD. Since this is Liferay portlet the dependeant libraries are in liferay-plugin-package.properties ( http://svn.liferay.com/browse/plugins/branches/6.0.x/portlets/sample-portal-client-portlet/docroot/WEB-INF/liferay-plugin-package.properties?r=HEAD). Make sure co place them on your application's classpath.
Hope this helps.
Sascha Handke, modificado 13 Anos atrás.
RE: Administer Portal programmatically
New Member Postagens: 2 Data de Entrada: 06/01/11 Postagens Recentes
Thanks for the answers. The WebService Approach seems to work for us.
A different approach we are currently evaluating is to call the ServiceFunctions from a Web-Application which is deployed within the Liferay Server. A call within a Servlet looks like that:
By doing in this manner we get the following exception:
Is there a way to provide or set somehow the Principal? When using the SOAP Service the Principal is set via the URL. When using the Http Service the Proincipal is set via the HttpPrincipal-Object. But how can I set the Principal for local calls?
Cheers
Sascha
A different approach we are currently evaluating is to call the ServiceFunctions from a Web-Application which is deployed within the Liferay Server. A call within a Servlet looks like that:
// Layout
LayoutService layoutService = LayoutServiceUtil.getService();
Layout layout = layoutService.addLayout(
16, false, 0, "ADD_LAYOUT", "Title", "Description", LayoutConstants.TYPE_PORTLET,
false, "/ADD_LAYOUT_URL");
By doing in this manner we get the following exception:
[b]com.liferay.portal.security.auth.PrincipalException[/b]
at com.liferay.portal.service.permission.GroupPermissionImpl.check(GroupPermissionImpl.java:51)
at com.liferay.portal.service.permission.GroupPermissionUtil.check(GroupPermissionUtil.java:41)
at com.liferay.portal.service.impl.LayoutServiceImpl.addLayout(LayoutServiceImpl.java:87)
at com.liferay.portal.service.impl.LayoutServiceImpl.addLayout(LayoutServiceImpl.java:74)
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:592)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy26.addLayout(Unknown Source)
at Connector.doGet(Connector.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:595)
Is there a way to provide or set somehow the Principal? When using the SOAP Service the Principal is set via the URL. When using the Http Service the Proincipal is set via the HttpPrincipal-Object. But how can I set the Principal for local calls?
Cheers
Sascha
Milen Dyankov, modificado 13 Anos atrás.
RE: Administer Portal programmatically
Regular Member Postagens: 171 Data de Entrada: 23/09/09 Postagens Recentes
Not quite sure what are you trying to do but if your code is running outside of Liferay's classloaders/session it will likely not work. If this is the case, you may find PortalDelegateServlet useful.