RE: Liferay Invitation module integrate in Liferay Rest Module

dipesh bhavsar, modified 6 Years ago. New Member Posts: 4 Join Date: 11/20/18 Recent Posts

We are trying to integrate liferay's com-liferay-invitation module in my own custome Rest Module, for that i have added gradle
depandancy in the rest module.

So After the gradle build i am able to use the member invitation related classes and methods.

https://github.com/liferay/com-liferay-invitation/blob/master/invitation-invite-members-web/src/main/java/com/liferay/invitation/invite/members/web/internal/portlet/InviteMembersPortlet.java

same way when i try to write the code for addMemberRequests i need a object of serviceContext and in the serviceContext they pass the request object for portleturl, createAccountUrl etc parameter.

 

So here my Question is in the Rest Module is there any way so i am able to access the http servlet or any other request.

 

 

Thanks in advance

thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts

Hi Dipesh, 

 

Are you saying that you are trying to access the web module from your REST module? if you are, then I would say that is the wrong solution. You should instead be trying to access the api module (which will in turn use the service) to perform your operation. If that is what you are doing, but you can't call the api method because you need a ServiceContext, you have two options.

 

1. Check to see if there is a method (or series of methods) that you can call that don't require the context object (though you probably already did this)

2. Build the service context yourself

 

The service context is just a helper class that caries a bunch of information to save you having to type out a million parameters. Not all the fields are necessarily populated, and even if the are, often onl;y a few of the actual fields are even used by the service. You sould be able to check the portal soource (service implementation) to see which fields are necessary and then build the service context yourself.