use of org.osgi.service.metatype.MetaTypeInformation in project ddf by codice.
the class ConfigurationAdminExt method getObjectClassDefinitions.
/**
* Returns the <code>ObjectClassDefinition</code> objects for the IDs returned by the
* <code>idGetter</code>. Depending on the <code>idGetter</code> implementation this will be for
* factory PIDs or plain PIDs.
*
* @param idGetter The {@link IdGetter} used to get the list of factory PIDs or PIDs from
* <code>MetaTypeInformation</code> objects.
* @return Map of <code>ObjectClassDefinition</code> objects indexed by the PID (or factory PID)
* to which they pertain
*/
private Map getObjectClassDefinitions(final IdGetter idGetter) {
Locale locale = Locale.getDefault();
final Map objectClassesDefinitions = new HashMap();
final MetaTypeService mts = this.getMetaTypeService();
if (mts != null) {
final Bundle[] bundles = this.getBundleContext().getBundles();
for (int i = 0; i < bundles.length; i++) {
final MetaTypeInformation mti = mts.getMetaTypeInformation(bundles[i]);
if (mti != null) {
final String[] idList = idGetter.getIds(mti);
for (int j = 0; idList != null && j < idList.length; j++) {
// After getting the list of PIDs, a configuration might be
// removed. So the getObjectClassDefinition will throw
// an exception, and this will prevent ALL configuration from
// being displayed. By catching it, the configurations will be
// visible
ObjectClassDefinition ocd = null;
try {
ocd = mti.getObjectClassDefinition(idList[j], locale.toString());
} catch (IllegalArgumentException ignore) {
// ignore - just don't show this configuration
}
if (ocd != null) {
objectClassesDefinitions.put(idList[j], ocd);
}
}
}
}
}
return objectClassesDefinitions;
}
Aggregations