Fórum

Liferay DXP get system settings via service

thumbnail
David Bougearel, modificado 6 Anos atrás.

Liferay DXP get system settings via service

Junior Member Postagens: 54 Data de Entrada: 30/06/16 Postagens Recentes
Hi,

We are using System settings from Control Panel in Liferay DXP SP2 and we need to know how to retreive those data (maybe by using a local service like UserLocalServiceUtil ?)

Could you help me on this point ?

Thanks a lot,
David.
thumbnail
David H Nebinger, modificado 6 Anos atrás.

RE: Liferay DXP get system settings via service

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
The settings are in Config Admin now, they are not available via a standard Liferay service.

Which scope did you use in your ExtendedObjectClassDefinition scope?









Come meet me at the 2017 LSNA!
thumbnail
David Bougearel, modificado 6 Anos atrás.

RE: Liferay DXP get system settings via service

Junior Member Postagens: 54 Data de Entrada: 30/06/16 Postagens Recentes
Hi David,

Thanks for your answer, we want to get the Elastic configuration from Foundation tab of the System settings.
We have put elastic configurations inside the com.liferay.portal.search.elasticsearch.configuration.ElasticsearchConfiguration.cfg in the liferay.home/osgi/configs and we need to get them programmatically.

Do you have any idea to achieve this goal ?

Thanks a lot,
David.
thumbnail
David Bougearel, modificado 6 Anos atrás.

RE: Liferay DXP get system settings via service

Junior Member Postagens: 54 Data de Entrada: 30/06/16 Postagens Recentes
It's seems like my post is related to this one : https://web.liferay.com/fr/community/forums/-/message_boards/message/78981039

This post ask how to get system settings information from java or jsp or ftl/vm emoticon
thumbnail
David H Nebinger, modificado 6 Anos atrás.

RE: Liferay DXP get system settings via service

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
So the best way to solve a problem like this is to see how the portal does it...

I searched the code for "ElasticsearchConfiguration" expecting that I'd find not only the interface for the configuration, but also examples on how Liferay gets access to it.

All of the examples for this one were using ConfigurableUtil to create an instance. Some were more complicated than others, but this one seemed straight forward:
https://github.com/dnebing/liferay-portal/blob/master/modules/apps/foundation/portal-search/portal-search-elasticsearch/src/main/java/com/liferay/portal/search/elasticsearch/connection/ElasticsearchConnectionManager.java










Come meet me at the 2017 LSNA!
thumbnail
David Bougearel, modificado 6 Anos atrás.

RE: Liferay DXP get system settings via service

Junior Member Postagens: 54 Data de Entrada: 30/06/16 Postagens Recentes
I was looking into that direction, thanks a lot for your help David !

Have a nice day emoticon
thumbnail
David Bougearel, modificado 6 Anos atrás.

RE: Liferay DXP get system settings via service

Junior Member Postagens: 54 Data de Entrada: 30/06/16 Postagens Recentes
Hi David,

I wanted to inject the ElasticsearchConnectionManager OSGI service inside my OSGI service by using the following :

private ElasticsearchConnectionManager esConnectionmanager;

@Reference(unbind = "-")
protected void setElasticsearchConnectionManager(ElasticsearchConnectionManager esConnectionmanager){
this.esConnectionmanager = esConnectionmanager;
}

I've added it as dependency :

<dependency>
<groupId>com.liferay</groupId>
<artifactId>com.liferay.portal.search.elasticsearch</artifactId>
<scope>provided</scope>
<version>2.1.4</version>
</dependency>

Unfortunately, with the bnd.file, the required package seems to not be exposed by liferay (com.liferay.portal.search.elasticsearch.connection -- Cannot be resolved) ; even by added it as import-package.

What i'm doing wrong in there ?

Thanks a lot,
David.
thumbnail
David H Nebinger, modificado 6 Anos atrás.

RE: Liferay DXP get system settings via service

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
David Bougearel:
What i'm doing wrong in there ?


Nothing.

For reasons that I don't totally understand, Liferay will export some packages but keep others private. I think the idea is that APIs can be public but they treat implementations as private. Unfortunately this means that usually we cannot access or use or extend their implementations which may be clean from an application architecture perspective, but as a platform perspective I think it's pretty short sighted.








Come meet me at the 2017 LSNA!
thumbnail
David Bougearel, modificado 6 Anos atrás.

RE: Liferay DXP get system settings via service

Junior Member Postagens: 54 Data de Entrada: 30/06/16 Postagens Recentes
Yes, from my point of view it's hard to understand how we can develop applications (portlets) without reuse what is in the liferay core and especially osgi services (like the elasticsearch client).

Anyway, thanks for your precious support David !

Best regards,
David.
thumbnail
David Bougearel, modificado 6 Anos atrás.

RE: Liferay DXP get system settings via service

Junior Member Postagens: 54 Data de Entrada: 30/06/16 Postagens Recentes
A user story in under study by liferay for the case : https://issues.liferay.com/browse/LPS-70480

I will keep an eye on it ;)