Expand my Community achievements bar.

SOLVED

How to validate OSGi Service properties from webconsole?

Avatar

Level 7

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

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

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

View solution in original post

7 Replies

Avatar

Level 2
        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

Avatar

Level 10

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

Avatar

Correct answer by
Employee Advisor

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

Avatar

Level 7

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.

Avatar

Employee Advisor

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

Avatar

Level 2
        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