It's all about the answers!

Ask a question

How to add custom properties to config page?


SEC Servizi (97123860) | asked Aug 07 '13, 8:39 a.m.
edited Oct 24 '13, 3:06 a.m.
We would add some custom properties in to the config page https://localhost/jazz/admin#action=com.ibm.team.repository.admin.configureAdvanced. Is it possible?
Thanks in advance.

Accepted answer


permanent link
sam detweiler (12.5k6195201) | answered Aug 09 '13, 10:47 a.m.
here is one of mine exactly

<code>
   <extension point="com.ibm.team.repository.service.serviceProvider">
           <serviceProvider
             componentId="com.xx.remoterepository"
            implementationClass="com.xx.repository.service.RepositoryFileService">
                   <provides>
                    <providedService interface="com.xx.repository.service.IRepositoryFileService"/>
                   </provides>
                   <prerequisites>
                   <requiredService
                         interface="com.ibm.team.repository.common.internal.IRepositoryRemoteService">
                   </requiredService>
                  <configurationProperties >     
                       <configurationProperty
                           accessPolicy="OPEN"
                           default="128"                                                 
                           name="sfdc.VolumeSize"
                           description="Max size (in MegaBytes) of files to copy into the RTC repository"                           
                           displayableName="Maximum file size to copy"
                           required="true"
                           type="INTEGER"
                           updatePolicy="NO_RESTART_REQUIRED">
                       </configurationProperty>
                       <configurationProperty
                           accessPolicy="OPEN"
                           default="idrive"                                                 
                           name="sfdc.VolumePrefix"
                           description="the network share name of the Shared volume (FTP server)"                           
                           displayableName="FTP Volume Share name"
                           required="true"
                           type="STRING"
                           updatePolicy="NO_RESTART_REQUIRED">
                       </configurationProperty>                      
               </configurationProperties>                    
                </prerequisites>                              
               </serviceProvider>
   </extension>
</code>
SEC Servizi selected this answer as the correct answer

3 other answers



permanent link
sam detweiler (12.5k6195201) | answered Aug 07 '13, 1:00 p.m.
edited Aug 07 '13, 1:01 p.m.
you have to attach the properties to a plugin. I have created my own services, and added properties.

see

https://jazz.net/forum/questions/62690/need-a-service-a-client-can-call-to-get-server-parameters

and you can only retrieve them THRU the plugin they are attached to.

permanent link
SEC Servizi (97123860) | answered Aug 08 '13, 3:38 a.m.
edited Aug 09 '13, 10:08 a.m.
The document at https://jazz.net/wiki/bin/view/Main/ConfigurationStory shows how to declare your configuration properties:

All configuration properties must be declared via extension point using the configurationProperties element. This element is nested within a prerequisites element. The prerequisites element is included in both serviceProvider elements as well as extensionService elements.

and how to consume your configuration properties:
As mentioned previously, configuration properties are owned by a particular service. When the activate method is called on a service, it can safely assume that all of its required configuration properties are accessible via protected methods on AbstractService. These methods are called get****ConfigProperty(propertyName)The stars are replaced with one of the four valid types(Integer, Long, Boolean, String)

We add the code below to our plugin.xml:
<extension
         point="com.ibm.team.repository.service.serviceProvider">
      <serviceProvider
            componentId="componentId"
            implementationClass="implementationClass">
            <provides>
            </provides>
         <prerequisites>
            <configurationProperties>
               <configurationProperty
                     accessPolicy="OPEN"
                     default="localhost"
                     description="HOSTNAME"
                     displayableName="HOSTNAME"
                     name="HOSTNAME"
                     required="true"
                     type="STRING"
                     updatePolicy="NO_RESTART_REQUIRED">
               </configurationProperty>
            </configurationProperties>
         </prerequisites>
      </serviceProvider>
   </extension>
but then there isn't any new custom properties at /jazz/admin#action=com.ibm.team.repository.admin.configureAdvanced... Any advice?
Thanks in advance.

Comments
Bo Chulindra commented Aug 09 '13, 10:27 a.m. | edited Aug 09 '13, 10:27 a.m.
JAZZ DEVELOPER

I tried using the code you pasted assuming that you don't actually have the <br> tags in the code. I see the following error in my log:

10:22:06,438 [Start Level Event Dispatcher] ERROR ository.common.transport.AbstractElementDescriptor  - Failed to process 'prerequisites' child named 'configurationproperties'
10:22:06,439 [Start Level Event Dispatcher] ERROR ository.common.transport.AbstractElementDescriptor  - The foo bundle's plugin.xml file contains a <provides> element that does not contain at least one nested element.
java.lang.IllegalArgumentException: The foo bundle's plugin.xml file contains a <provides> element that does not contain at least one nested element.


Have you looked at your application's logs for errors? My guess is that you will see the same error in there.

Change your <provides> tag to something like this and see if it works:

<provides>
    <providedService interface="interface">
    </providedService>
</provides>


SEC Servizi commented Aug 09 '13, 11:25 a.m.

Yes, the XML contains the providedService tag, too. It was the copy-paste to fail... -.-


permanent link
SEC Servizi (97123860) | answered Aug 09 '13, 11:21 a.m.
edited Aug 09 '13, 11:22 a.m.
Sam, your interface is: 
package com.xx.repository.service;
public interface IRepositoryFileService {
    //  ...
}
and your implementation class is:
package com.xx.repository.service;
import com.ibm.team.repository.service.AbstractService;
public class RepositoryFileService extends AbstractService implements IRepositoryFileService {
public RepositoryFileService() {
super();
}

@Override
public void activate() {
// ...
}
}
If so, even the Java code seems like mine... 

Comments
sam detweiler commented Aug 09 '13, 4:25 p.m. | edited Aug 09 '13, 4:34 p.m.

sounds like your plugin did not load, cause you forgot to identify the service NAME

this is from yours                               
           
<provides>
           
</provides>


this from mine
            <provides>                <providedservice interface="com.xx.repository.service.IRepositoryFileService"/>            </provides>


SEC Servizi commented Aug 26 '13, 9:23 a.m.

You're right, I forgot to request the Jazz server reset...

Now it works, thanks!

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.