OSGi properties value should not blank

Avatar

Avatar

Jaggu_Accenture

Avatar

Jaggu_Accenture

Jaggu_Accenture

18-07-2018

Hi Team,

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

1530708_pastedImage_0.png

Regards,

Jaganath

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K
smacdonald2008

19-07-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

Answers (9)

Answers (9)

Avatar

Avatar

PuzanovsP

MVP

Avatar

PuzanovsP

MVP

PuzanovsP
MVP

19-07-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

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K
smacdonald2008

18-07-2018

For general OSGi configurations - see - Configuring OSGi

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

Avatar

Avatar

Jaggu_Accenture

Avatar

Jaggu_Accenture

Jaggu_Accenture

20-07-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.

Avatar

Avatar

Jaggu_Accenture

Avatar

Jaggu_Accenture

Jaggu_Accenture

20-07-2018

Thanks Smacdonald.

Avatar

Avatar

Jaggu_Accenture

Avatar

Jaggu_Accenture

Jaggu_Accenture

19-07-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

Avatar

Avatar

PuzanovsP

MVP

Avatar

PuzanovsP

MVP

PuzanovsP
MVP

19-07-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

Avatar

Avatar

Jaggu_Accenture

Avatar

Jaggu_Accenture

Jaggu_Accenture

18-07-2018

Yes , nowhere its mentioned.

Avatar

Avatar

Jaggu_Accenture

Avatar

Jaggu_Accenture

Jaggu_Accenture

18-07-2018

Thanks  Smacdonal,

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

1530952_pastedImage_0.png

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K
smacdonald2008

18-07-2018

Do you mean for a custom service or general ones?