OSGi properties value should not blank | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
smacdonald2008
smacdonald2008Accepted solution
Level 10
Jul 19, 2018 10:42 AM UTC

Exactly - you are consuming these values in Java code. If in your Java code - the OSGi value is empty - set a default value in your code so your logic does not break. See this articel for more information - Reading OSGi Configuration Values for Adobe Experience Manager 6.3

10 replies

Jaggu_Accenture
Level 2
Jul 20, 2018 6:31 PM UTC

Thanks Peter, I need one more calcification can I give position to OSGi fields means in OSGi one field is coming on middle can I move this filed to top.

Translate
Jaggu_Accenture
Level 2
Jul 20, 2018 6:27 PM UTC

Thanks Smacdonald.

Translate
smacdonald2008
smacdonald2008Accepted solution
Level 10
Jul 19, 2018 10:42 AM UTC

Exactly - you are consuming these values in Java code. If in your Java code - the OSGi value is empty - set a default value in your code so your logic does not break. See this articel for more information - Reading OSGi Configuration Values for Adobe Experience Manager 6.3

Translate
Peter_Puzanovs
New Participant
Jul 19, 2018 8:41 AM UTC

Hi Jaggu,

That sounds like not very durable design if a single mis-config can break 'whole system'. Consider changing your OSGi code in a way that default value is always set. E.g. your Java code know's what the defaults are.

Regards,

Peter

Translate
Jaggu_Accenture
Level 2
Jul 19, 2018 8:11 AM UTC

Thanks for your response, you are correct Peter  but in OSGi we are using some key for lead submit. In case this property is blank then the whole system is breaking even though there is default value. So we need validation for not blank.

Regards,

Jaggu

Translate
Peter_Puzanovs
New Participant
Jul 19, 2018 7:41 AM UTC

Dear Jaggu,

Not aware of such setting.

You are viewing it of slightly wrong angle. Normally, your OSGi config get's consumes in OSGi Service.

There you can take these parameters via Java method.

Such as @Activate or @Modified, there you can always make you validations for the user input.

In cases when config isEmpty or isInvalid, you don't have to add that config in. Instead, in OSGi you can define default value.

In case if I'm wrong you can verify implementation of felix/configadmin at trunk · apache/felix · GitHub where you would find the code that's running inside your configAdmin. *Update correct place to look at javascript felix/config.js at trunk · apache/felix · GitHub 

Alternatively, you can look at awesome writeup/talk by Jörg Sling Context-Aware configuration

With this sytem you can use Touch UI and can make any input pre-validated by standard AEM UI systems.

Hope this helps.

Regards,

Peter

Translate
Jaggu_Accenture
Level 2
Jul 19, 2018 5:21 AM UTC

Yes , nowhere its mentioned.

Translate
Jaggu_Accenture
Level 2
Jul 19, 2018 5:19 AM UTC

Thanks  Smacdonal,

Yes its custom OSGi services and also is it possible to make mandatory the sling:OsgiConfig property fields as below.

Translate
smacdonald2008
Level 10
Jul 18, 2018 7:41 PM UTC

For general OSGi configurations - see - Configuring OSGi

However no mention of how to make any one field mandatory.

Translate
smacdonald2008
Level 10
Jul 18, 2018 7:40 PM UTC

Do you mean for a custom service or general ones?

Translate