log.debug(
"Loading capability '{}' of type '{}' with properties '{}'",
id, item.getType(), item.getProperties()
);
final CapabilityDescriptor descriptor = capabilityDescriptorRegistry.get(capabilityType(item.getType()));
if (descriptor == null) {
log.warn(
"Capabilities persistent storage (capabilities.xml?) contains an capability of unknown type {} with"
+ " id {}. This capability will not be loaded", item.getType(), id
);
continue;
}
Map<String, String> properties = decryptValuesIfNeeded(descriptor, item.getProperties());
if (descriptor.version() != item.getVersion()) {
log.debug(
"Converting capability '{}' properties from version '{}' to version '{}'",
id, item.getVersion(), descriptor.version()
);
try {
properties = descriptor.convert(properties, item.getVersion());
if (properties == null) {
properties = Collections.emptyMap();
}
if (log.isDebugEnabled()) {
log.debug(
"Converted capability '{}' properties '{}' (version '{}') to '{}' (version '{}')",
id, item.getProperties(), item.getVersion(),
encryptValuesIfNeeded(descriptor, properties), descriptor.version()
);
}
}
catch (Exception e) {
log.error(
"Failed converting capability '{}' properties '{}' from version '{}' to version '{}'."
+ " Capability will not be loaded",
id, item.getProperties(), item.getVersion(), descriptor.version(), e
);
continue;
}
capabilityStorage.update(id, new CapabilityStorageItem(
descriptor.version(), item.getType(), item.isEnabled(), item.getNotes(), properties)
);
}
final DefaultCapabilityReference reference = create(id, capabilityType(item.getType()), descriptor);