class RootServiceResponseFactory extends
    AbstractRootServiceResponseFactory {

  @Override
  public Set<RootServiceResponse> getRootServices(RootServiceRequest request) throws ObjectNotFoundException {
    
    Set<RootServiceResponse> response;
    
    String serviceName = null;
    
    if (request != null)
      serviceName = request.getServiceName();

    if (serviceName != null) {
      RootService service;
      try {
        service = RootService.valueOf(serviceName);
      }
      catch (IllegalArgumentException ex) {
        throw new ObjectNotFoundException("Root service name: " + serviceName);
      }
      
      response = Collections.singleton(new RootServiceResponse(service.toString()));
    } else {
      response = new HashSet<>();
      
      for (RootService service: RootService.values())
        response.add(new RootServiceResponse(service.toString()));
    }    
    return response;
  }

}