OSGi properties value should not blank | Community
Skip to main content
Jaggu_Accenture
Level 2
July 18, 2018
Solved

OSGi properties value should not blank

  • July 18, 2018
  • 10 replies
  • 3630 views

Hi Team,

Please any body suggest me how to make OSGi property value should mandatory. Please find the below screenshot

Regards,

Jaganath

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

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

smacdonald2008
Level 10
July 18, 2018

Do you mean for a custom service or general ones?

smacdonald2008
Level 10
July 18, 2018

For general OSGi configurations - see - Configuring OSGi

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

Jaggu_Accenture
Level 2
July 19, 2018

Thanks  Smacdonal,

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

Jaggu_Accenture
Level 2
July 19, 2018

Yes , nowhere its mentioned.

Peter_Puzanovs
Community Advisor
Community Advisor
July 19, 2018

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

Jaggu_Accenture
Level 2
July 19, 2018

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

Peter_Puzanovs
Community Advisor
Community Advisor
July 19, 2018

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

smacdonald2008
smacdonald2008Accepted solution
Level 10
July 19, 2018

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

Jaggu_Accenture
Level 2
July 20, 2018

Thanks Smacdonald.

Jaggu_Accenture
Level 2
July 20, 2018

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.