[ome-users] How to access OMERO config via the API?
Chris Allan
callan at lifesci.dundee.ac.uk
Tue Apr 3 09:14:18 BST 2012
In order to access the ServiceFactory when inside the the server the bean has to be instantiated in a particular way in order to receive the correct state. As your HyNewUserGroupBean's calling context is during login you have no ServiceFactory, the user is not yet logged in. Your best bet is to inject the configuration value in as an argument to the constructor of HyNewUserGroupBean:
...
<bean id="hyldapbean" class="hyldap.HyNewUserGroupBean"/>
...
becomes:
...
<bean id="hyldapbean" class="hyldap.HyNewUserGroupBean">
<constructor-arg value="${hyldap.configFile}"/>
</bean>
...
and...
...
public HyNewUserGroupBean() {
}
...
becomes:
...
public HyNewUserGroupBean(String configFile) {
// Do something with the constructor argument
...
}
...
You may also need to place a default value into etc/omero.properties:
...
# Configuration options for hyldap
hyldap.configFile=
...
-Chris
On 2 Apr 2012, at 17:37, Harri Jäälinoja wrote:
>
> Hi,
>
> I am trying to make it possible to configure my NewUserGroupBean implementation:
> https://gist.github.com/2172934#file_src%2Fhyldap%2Fhy_new_user_group_bean.java
>
> This is what I cut and pasted from elsewhere in the OMERO project:
> ServiceFactory sf = new ServiceFactory();
> IConfig c = sf.getConfigService();
> String hyldapConfig = c.getConfigValue(CONFIGFILE);
>
> But when I try to run it, it goes like this:
> org.springframework.beans.factory.access.BootstrapException: Unable to return specified BeanFactory instance: factory key [ome.client], from group with resource name [classpath*:beanRefContext.xml]; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'ome.client' is defined
> at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:409)
> at ome.system.OmeroContext.getInstance(OmeroContext.java:203)
> at ome.system.ServiceFactory.<init>(ServiceFactory.java:81)
> at hyldap.HyNewUserGroupBean.groups(HyNewUserGroupBean.java:59)
> at ome.logic.LdapImpl.handleGroupSpecBean(LdapImpl.java:476)
>
> What is the proper way to access the configuration? My idea is to give in OMERO configuration a path to a file that will contain a list of allowed group names found in our LDAP and the OMERO group names they should be mapped to.
>
> omero config set "hyldap.configFile" "/home/omero/hyldapconfig.txt"
>
> hyldapconfig.txt:
> "uid=grp-A91900-bi-vart,ou=alma_workgroups,ou=groups,o=hy","BI-Vartiainen"
> "uid=grp-A34520-biu,ou=alma_workgroups,ou=groups,o=hy","BIU"
> etc... might make that xml, just to have a ready-made parser to use. In the first implementation I hard-coded these in the bean, which is not so nice to maintain.
>
> Cheers,
> Harri
>
> --
> __________________________________________________
> Harri Jäälinoja
> Light Microscopy Unit
> Institute of Biotechnology, University of Helsinki
> http://www.biocenter.helsinki.fi/bi/lmu/
> +358 9 191 59370 fax +358 9 191 59366
>
> _______________________________________________
> ome-users mailing list
> ome-users at lists.openmicroscopy.org.uk
> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users
More information about the ome-users
mailing list