Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Liferay Polls, Microblogs & Invitation API integration as web service
Hi All,
We are working on application using Liferay 7 DXP supported Colloboration and Social networking modules. We have backend application developed in Liferay and mobile applications in React Native.
We have used com.liferay.polls.api
, com.liferay.invitation.invite.members.api.
We are able to integrate these APIs inside liferay setup and can work from liferay portlets. But when the same APIs if we try to expose as REST API writting service layer for mobile application integration then we are not getting some of the parameter actionrequest shown in below sample and due to which our APIs are not working as a web service.
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
Can any one pleae help us in this or guide us to solve this issue.
Your help is appreciated !!
Thanks
Dipesh Bhavsar
Hi Dipesh,
The good news is that both those classes are just beans and you can actually build them yourself. For example, you can do --
ServiceContext serviceContext = new ServiceContext(); serviceContext.setXXX(); ...
Looking at the code you provided, you only need the userId from the themeDisplay, and I think you should be able to get that from the request using the PortalUtil (really you should have a private member like this --)
@Reference(ubind="-") private Portal _portal;
.. and then use that to get the user id with the request --
long userId = _portal.getUserId(request);
.. to get the Login url, you can use this --
String securePortalURL = PortalUtil.getPortalURL(request, secure); String urlSignIn = securePortalURL.concat(mainPath).concat("/portal/login");
.. but all of this is based on the assumption that I understand what you are doing. IF you could post your code to show where it is not working for you, that would be the best approach as we could offer advice on how to alter exactly what you are working with.
Thanks Andrew for your quick response.
We have followed the same approach and now able to fullfill our requirements.
Thanks a lot again.
Powered by Liferay™