Skip to main content
Dinu_Arya
Level 6
Oct 16, 2015 2:27 AM UTC
Solved

How to validate OSGi Service properties from webconsole?

Hi,

I have written a service and added some properties using @Property . While configuring the service from web console, I have to show some user friendly message or some alert to an author if he/she enters more than the allowed items/count(Max count: 5). Is it possible to validate these fields? Pls let me know.

Thanks,

AryA

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
joerghoh
joerghohAccepted solution
Adobe Employee
Oct 16, 2015 2:27 AM UTC

Hi,

I would expect, that an administrator (or someone, who is supposed to change the OSGI configuration) is allowed to read logfiles, so you can validate your parameters in the code. There is no possibility to add validation logic in the felix config forms. When you have a multi-value parameter, you can limit the maximum number of entries via the property, and this setting is validated (the UI doesn't let you create more than 5 entries for example).

Jörg

7 replies

Venkata_Kumar
Level 2
Oct 16, 2015 2:27 AM UTC
        Usually,authors are not supposed to access Felix console..coz..if they delete something or click on something else, it may screw entire system. Ideally, only admins are allowed to do changes.. If you want authors to change config,place the config at your application level config nodes and give option for authors to change.In that case, you can also add validations
Translate
joerghoh
Adobe Employee
Adobe Employee
Oct 16, 2015 2:27 AM UTC

Hi,

you can do something like this:

@Property(label="limited parameter", description="use at max 5", cardinality=5) private String[] myParams;

See the documentation of cardinality on http://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-plugin/scr-annotations.html#property

Translate
smacdonald2008
Level 10
Oct 16, 2015 2:27 AM UTC
Dinu_Arya
Dinu_AryaAuthor
Level 6
Oct 16, 2015 2:27 AM UTC

Jorg,

ya. But admin might not know what is the exact issue. Can u pls share how can I declare multi-value parameter?  Pls let me know how can I limit the maximum number of entries via the property

Thanks A lot,

AryA.

Translate
joerghoh
Adobe Employee
joerghohAdobe EmployeeAccepted solution
Adobe Employee
Oct 16, 2015 2:27 AM UTC

Hi,

I would expect, that an administrator (or someone, who is supposed to change the OSGI configuration) is allowed to read logfiles, so you can validate your parameters in the code. There is no possibility to add validation logic in the felix config forms. When you have a multi-value parameter, you can limit the maximum number of entries via the property, and this setting is validated (the UI doesn't let you create more than 5 entries for example).

Jörg

Translate
smacdonald2008
Level 10
Oct 16, 2015 2:27 AM UTC

I am not aware of how to let authors know through the Felix web console where you install the OSGi bundle and place it into an active state. One option that you have is to write an error message in the AEM log file if the property contains an invalid value.  

Also - take a look at this AEM topic:

http://docs.adobe.com/docs/en/cq/current/deploying/configuring_osgi.html

Translate
Venkata_Kumar
Level 2
Oct 16, 2015 2:27 AM UTC
        Usually,authors are not supposed to access Felix console..coz..if they delete something or click on something else, it may screw entire system. Ideally, only admins are allowed to do changes.. If you want authors to change config,place the config at your application level config nodes and give option for authors to change.In that case, you can also add validations
Translate