public static CapabilityStatusXO asCapabilityStatus(final CapabilityReference reference) {
checkNotNull(reference);
CapabilityDescriptor descriptor = reference.context().descriptor();
Capability capability = reference.capability();
final CapabilityStatusXO capabilityStatus = new CapabilityStatusXO()
.withCapability(asCapability(reference))
.withTypeName(descriptor.name())
.withActive(reference.context().isActive())
.withError(reference.context().hasFailure());
try {
capabilityStatus.setDescription(capability.description());
}
catch (Throwable e) {
log.warn(
"Failed to render description of capability '{}/{}' due to {}/{}",
reference.context().type(), reference.context().id(),
e.getClass().getName(), e.getMessage(), log.isDebugEnabled() ? e : null
);
capabilityStatus.setDescription(null);
}
try {
capabilityStatus.setStatus(capability.status());
}
catch (Throwable e) {
log.warn(
"Failed to render status of capability '{}/{}' due to {}/{}",
reference.context().type(), reference.context().id(),