Examples of CapabilityStatusXO


Examples of org.sonatype.nexus.capabilities.model.CapabilityStatusXO

    return settings().getCapability().getId();
  }

  @Override
  protected CapabilityStatusXO createSettings(final String id) {
    return new CapabilityStatusXO()
        .withCapability(
            new CapabilityXO()
                .withId(id)
                .withEnabled(true)
                .withProperties(Lists.<PropertyXO>newArrayList())
View Full Code Here

Examples of org.sonatype.nexus.capabilities.model.CapabilityStatusXO

    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(),
          e.getClass().getName(), e.getMessage(), log.isDebugEnabled() ? e : null
      );
      capabilityStatus.setStatus(null);
    }
    capabilityStatus.setStateDescription(reference.context().stateDescription());

    Set<Tag> tags = Sets.newHashSet();

    try {
      if (descriptor instanceof Taggable) {
        Set<Tag> tagSet = ((Taggable) descriptor).getTags();
        if (tagSet != null) {
          tags.addAll(tagSet);
        }
      }
    }
    catch (Throwable e) {
      log.warn(
          "Failed to retrieve tags from capability descriptor '{}' due to {}/{}",
          reference.context().type(),
          e.getClass().getName(), e.getMessage(), log.isDebugEnabled() ? e : null
      );
    }
    try {
      if (capability instanceof Taggable) {
        Set<Tag> tagSet = ((Taggable) capability).getTags();
        if (tagSet != null) {
          tags.addAll(tagSet);
        }
      }
    }
    catch (Throwable e) {
      log.warn(
          "Failed to retrieve tags from capability '{}/{}' due to {}/{}",
          reference.context().type(), reference.context().id(),
          e.getClass().getName(), e.getMessage(), log.isDebugEnabled() ? e : null
      );
    }

    List<TagXO> tagXOs = Lists.transform(
        Lists.newArrayList(Collections2.filter(tags, Predicates.<Tag>notNull())),
        new Function<Tag, TagXO>()
        {
          @Override
          public TagXO apply(final Tag input) {
            return new TagXO().withKey(input.key()).withValue(input.value());
          }
        }
    );

    if (!tagXOs.isEmpty()) {
      capabilityStatus.setTags(tagXOs);
    }

    return capabilityStatus;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.