public static DescribeServicesResponseType describeService(final DescribeServicesType request) {
    final DescribeServicesResponseType reply = request.getReply();
    Topology.touch(request);
    if (request.getServices().isEmpty()) {
      final ComponentId compId =
          (request.getByServiceType() != null)
              ? ComponentIds.lookup(request.getByServiceType().toLowerCase())
              : Empyrean.INSTANCE;
      final boolean showEventStacks = Boolean.TRUE.equals(request.getShowEventStacks());
      final boolean showEvents = Boolean.TRUE.equals(request.getShowEvents()) || showEventStacks;

      final Function<ServiceConfiguration, ServiceStatusType> transformToStatus =
          ServiceConfigurations.asServiceStatus(showEvents, showEventStacks);
      final List<Predicate<ServiceConfiguration>> filters =
          new ArrayList<Predicate<ServiceConfiguration>>() {
            {
              if (request.getByPartition() != null) {
                Partitions.exists(request.getByPartition());
                this.add(Filters.partition(request.getByPartition()));
              }
              if (request.getByState() != null) {
                final Component.State stateFilter =
                    Component.State.valueOf(request.getByState().toUpperCase());
                this.add(Filters.state(stateFilter));
              }
              if (!request.getServiceNames().isEmpty()) {
                this.add(Filters.name(request.getServiceNames()));
              }
              this.add(Filters.host(request.getByHost()));
              this.add(
                  Filters.listAllOrInternal(
                      request.getListAll(),
                      request.getListUserServices(),
                      request.getListInternal()));
            }
          };
      final Predicate<Component> componentFilter = Filters.componentType(compId);
      final Predicate<ServiceConfiguration> configPredicate = Predicates.and(filters);

      List<ServiceConfiguration> replyConfigs = Lists.newArrayList();
      for (final Component comp : Components.list()) {
        if (componentFilter.apply(comp)) {
          Collection<ServiceConfiguration> acceptedConfigs =
              Collections2.filter(comp.services(), configPredicate);
          replyConfigs.addAll(acceptedConfigs);
        }
      }
      ImmutableList<ServiceConfiguration> sortedReplyConfigs =
          ServiceOrderings.defaultOrdering().immutableSortedCopy(replyConfigs);
      final Collection<ServiceStatusType> transformedReplyConfigs =
          Collections2.transform(sortedReplyConfigs, transformToStatus);
      reply.getServiceStatuses().addAll(transformedReplyConfigs);
    } else {
      for (ServiceId s : request.getServices()) {
        reply.getServiceStatuses().add(TypeMappers.transform(s, ServiceStatusType.class));
      }
    }
    return reply;
  }
    public DescribeServicesResponseType user(final DescribeServicesType request) {
      final DescribeServicesResponseType reply = request.getReply();
      /**
       * Only show public services to normal users. Allow for filtering by component and state w/in
       * that set.
       */
      final List<Predicate<ServiceConfiguration>> filters =
          new ArrayList<Predicate<ServiceConfiguration>>() {
            {
              this.add(Filters.publicService());
              if (request.getByPartition() != null) {
                this.add(Filters.partition(request.getByPartition()));
              }
              if (request.getByState() != null) {
                this.add(
                    Filters.state(Component.State.valueOf(request.getByState().toUpperCase())));
              }
            }
          };
      final Predicate<Component> componentFilter =
          (Predicate<Component>)
              (request.getByServiceType() != null
                  ? Filters.componentType(
                      ComponentIds.lookup(request.getByServiceType().toLowerCase()))
                  : Predicates.alwaysTrue());
      final Predicate<ServiceConfiguration> configPredicate = Predicates.and(filters);

      final Collection<ServiceConfiguration> replyConfigs = Lists.newArrayList();
      for (final Component comp : Iterables.filter(Components.list(), componentFilter)) {
        replyConfigs.addAll(Collections2.filter(comp.services(), configPredicate));
      }
      final ImmutableList<ServiceConfiguration> sortedReplyConfigs =
          ServiceOrderings.defaultOrdering().immutableSortedCopy(replyConfigs);
      final Collection<ServiceStatusType> replyStatuses =
          Collections2.transform(
              sortedReplyConfigs, ServiceConfigurations.asServiceStatus(false, false));
      reply.getServiceStatuses().addAll(replyStatuses);
      return reply;
    }