Foros de discusión

Can you use Liferay api in a nonliferay project?

Paige Lowe, modificado hace 9 años.

Can you use Liferay api in a nonliferay project?

Junior Member Mensajes: 42 Fecha de incorporación: 11/11/14 Mensajes recientes
I have code from a nonliferay project (a webpage crawler) that I would like to adapt to add documents to Liferay's search index. Is it possible to use things from Liferay's api (documentimpl, document, company, company ids etc) without turning it into a hook or a plugin of some sort? I have the ide and the sdk, I'd just rather adapt something that works instead of trying to make something from scratch.
thumbnail
David H Nebinger, modificado hace 9 años.

RE: Can you use Liferay api in a nonliferay project?

Liferay Legend Mensajes: 14914 Fecha de incorporación: 2/09/06 Mensajes recientes
Sure, Liferay has a number of APIs that you can invoke via SOAP.

Sometimes, however, I find it's easier to do implement a Liferay-side method to encapsulate all of the Liferay details rather than trying to invoke Liferay's Soap methods, then you plug into that method externally.
Paige Lowe, modificado hace 9 años.

RE: Can you use Liferay api in a nonliferay project?

Junior Member Mensajes: 42 Fecha de incorporación: 11/11/14 Mensajes recientes
Thank you! How would I do either of those things? Alternatively where could I look to find the correct apis? (Sorry, I'm a super novice at...everything)
Paige Lowe, modificado hace 9 años.

RE: Can you use Liferay api in a nonliferay project?

Junior Member Mensajes: 42 Fecha de incorporación: 11/11/14 Mensajes recientes
If it helps to be more specific, I have a web crawler that gets documents from another website that I need to add to the search index. I think I found the right methods in the API to do this, but in order to use them, I need to get my company id and search engine and I'm not sure the methods I found to do those things will work. More importantly, I want to make sure I connect to my instance of liferay correctly so things will actually add to my search results. How can I do that correctly? If there's some way to just open a connection then use the api stuff, that would be ideal. Is that possible?
thumbnail
David H Nebinger, modificado hace 9 años.

RE: Can you use Liferay api in a nonliferay project?

Liferay Legend Mensajes: 14914 Fecha de incorporación: 2/09/06 Mensajes recientes
Right, so this is an example of a perhaps irrelevant bit of data - the company id. So liferay supports having multiple "companies" under one instance, but typically we have only one. I suspect you have but one company yourself.

So personally I'd build a method to accept whatever parameters you intend on passing/searching with, then inside the method use obvious values that make sense for you, such as the default company id. This will allow your calling piece to focus on providing the information it is concerned about, but your service implementation can use obvious values.

It will also allow you to hide details of invoking the Liferay API, such as here if you want to query for the default company id and then invoke a search method or something, you hide all of those details within your implementation.

As to how you do such a thing, well you can use ServiceBuilder to generate your framework for implementing the service.

Being a super newbie, I'm sure some of this will make sense yet some (i.e. the ServiceBuilder) will not. I'd recommend reading Liferay in Action in order to learn more about Liferay internals. It's targeted at developers and will probably give you just what you'll need to finish the project.
Paige Lowe, modificado hace 9 años.

RE: Can you use Liferay api in a nonliferay project?

Junior Member Mensajes: 42 Fecha de incorporación: 11/11/14 Mensajes recientes
Thanks, I'll start reading it now.