class SpaceController {

  @RequestMapping(
      value = "search",
      method = RequestMethod.GET,
      produces = {"application/json;charset=UTF-8"})
  public ResponseEntity<List<Space>> searchSpaces(
      @RequestParam(value = "propertyName", required = true) String propertyName,
      @RequestParam(value = "mode", required = false, defaultValue = "EQUALS") ComparisonMode mode,
      @RequestParam(value = "caseSensitivity", required = false, defaultValue = "CASE_SENSITIVE")
          CaseSensitivity caseSensitivity,
      @RequestParam(value = "value", required = true) String[] value,
      @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false)
          String tenant) {

    // Check whether tenant exists or retrieve default
    Tenant t = null;
    try {
      t = this.tenantRepository.getTenant(tenant);
    } catch (Exception e) {
      log.error("Error retrieving tenant: " + e);
      return new ResponseEntity<List<Space>>(HttpStatus.NOT_FOUND);
    }
    try {
      final StringList filter = new StringList();
      filter.addAll(value);

      final List<Space> matching_spaces = new ArrayList<Space>();

      // Loop over all spaces and compare the value of the given property
      final List<Space> spaces = this.spaceRepository.findAllTenantSpaces(t.getTenantToken());
      for (Space s : spaces) {
        final String p = s.getPropertyValue(propertyName);
        if (p != null && s.isPublic() && filter.contains(p, mode, caseSensitivity))
          matching_spaces.add(s);
      }
      return new ResponseEntity<List<Space>>(matching_spaces, HttpStatus.OK);
    } catch (EntityNotFoundException enfe) {
      return new ResponseEntity<List<Space>>(HttpStatus.NOT_FOUND);
    }
  }

  @Autowired  SpaceController(
      TenantRepository tenantRepository,
      SpaceRepository spaceRepository,
      ApplicationRepository appRepository,
      ApplicationExporter appExporter,
      Filter cacheFilter);

}