@Test public void testSearchSpaces() throws Exception { assertEquals(0, this.spaceRepository.count()); final Tenant d_tenant = this.createDefaultTenant(); final Space d_space = this.createSpace(d_tenant, TEST_DEFAULT_SPACE, true); assertEquals(1, this.spaceRepository.count()); final String space_name = "foo"; org.eclipse.steady.shared.json.model.Space new_shared_space = new org.eclipse.steady.shared.json.model.Space(); new_shared_space.setSpaceName("foo"); new_shared_space.setExportConfiguration(ExportConfiguration.OFF); new_shared_space.setSpaceDescription("bar"); new_shared_space.setOwnerEmails( new HashSet<String>(Arrays.asList(new String[] {"foo@bar.com"}))); final List<org.eclipse.steady.shared.json.model.Property> props = new ArrayList<org.eclipse.steady.shared.json.model.Property>(); props.add( new org.eclipse.steady.shared.json.model.Property( PropertySource.USER, "propName", "propValue")); new_shared_space.setProperties(props); MockHttpServletRequestBuilder post_builder = post("/spaces") .content(JacksonUtil.asJsonString(new_shared_space)) .contentType(MediaType.APPLICATION_JSON) .header(Constants.HTTP_TENANT_HEADER, d_tenant.getTenantToken()) .accept(MediaType.APPLICATION_JSON); MvcResult result = mockMvc .perform(post_builder) .andExpect(status().isCreated()) .andExpect(content().contentType(contentType)) .andExpect(jsonPath("$.default", is(false))) .andExpect(jsonPath("$.spaceName", is(space_name))) .andReturn(); new_shared_space.setPublic(false); post_builder = post("/spaces") .content(JacksonUtil.asJsonString(new_shared_space)) .contentType(MediaType.APPLICATION_JSON) .header(Constants.HTTP_TENANT_HEADER, d_tenant.getTenantToken()) .accept(MediaType.APPLICATION_JSON); result = mockMvc .perform(post_builder) .andExpect(status().isCreated()) .andExpect(content().contentType(contentType)) .andExpect(jsonPath("$.default", is(false))) .andExpect(jsonPath("$.spaceName", is(space_name))) .andReturn(); assertEquals(3, this.spaceRepository.count()); MockHttpServletRequestBuilder search_builder = get("/spaces/search") .param("propertyName", "propName") .param("value", "xyz", "abc") .header(Constants.HTTP_TENANT_HEADER, d_tenant.getTenantToken()) .accept(MediaType.APPLICATION_JSON); result = mockMvc.perform(search_builder).andExpect(status().isOk()).andReturn(); org.eclipse.steady.shared.json.model.Space[] search_result = (org.eclipse.steady.shared.json.model.Space[]) JacksonUtil.asObject( result.getResponse().getContentAsString(), org.eclipse.steady.shared.json.model.Space[].class); assertEquals(0, search_result.length); search_builder = get("/spaces/search") .param("propertyName", "propName") .param("value", "xyz", "abc", "propValue") .header(Constants.HTTP_TENANT_HEADER, d_tenant.getTenantToken()) .accept(MediaType.APPLICATION_JSON); result = mockMvc.perform(search_builder).andExpect(status().isOk()).andReturn(); search_result = (org.eclipse.steady.shared.json.model.Space[]) JacksonUtil.asObject( result.getResponse().getContentAsString(), org.eclipse.steady.shared.json.model.Space[].class); assertEquals( 1, search_result.length); search_builder = get("/spaces/search") .param("propertyName", "propName") .header(Constants.HTTP_TENANT_HEADER, d_tenant.getTenantToken()) .accept(MediaType.APPLICATION_JSON); mockMvc.perform(search_builder).andExpect(status().isBadRequest()); }
@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) { 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>(); 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); } }
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) { 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>(); 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); } } }
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) { 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>(); 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); }
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) { 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>(); 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); @RequestMapping( value = "", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) ResponseEntity<Collection<Space>> getAllSpaces(
      @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false)
          String tenant); @RequestMapping( value = "default", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) ResponseEntity<Space> getDefaultSpace(
      @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false)
          String tenant); @RequestMapping( value = "search", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) 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); @RequestMapping(value = "/{token:.+}", method = RequestMethod.OPTIONS) ResponseEntity<Space> isSpaceExisting(
      @PathVariable String token,
      @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false)
          String tenant); @RequestMapping(value = "/{token:.+}", method = RequestMethod.GET) ResponseEntity<Space> getSpace(
      @PathVariable String token,
      @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false)
          String tenant); @RequestMapping( value = "", method = RequestMethod.POST, consumes = {"application/json;charset=UTF-8"}, produces = {"application/json;charset=UTF-8"}) ResponseEntity<Space> createSpace(
      @RequestBody Space space,
      @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false)
          String tenant); @RequestMapping( value = "/{token:.+}", method = RequestMethod.PUT, consumes = {"application/json;charset=UTF-8"}, produces = {"application/json;charset=UTF-8"}) ResponseEntity<Space> modifySpace(
      @PathVariable String token,
      @RequestBody Space new_space,
      @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false)
          String tenant); @RequestMapping(value = "/{token:.+}", method = RequestMethod.POST) ResponseEntity<Space> cleanSpace(
      @PathVariable String token,
      @RequestParam(value = "clean", required = true) Boolean clean,
      @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false)
          String tenant); @RequestMapping(value = "/{token:.+}", method = RequestMethod.DELETE) ResponseEntity<Space> deleteSpace(
      @PathVariable String token,
      @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false)
          String tenant); @RequestMapping(value = "/{token:.+}/apps", method = RequestMethod.GET) void getApplications(
      @PathVariable String token,
      @RequestParam(value = "includeSpaceProperties", required = false, defaultValue = "")
          final String[] includeSpaceProperties,
      @RequestParam(value = "includeGoalConfiguration", required = false, defaultValue = "")
          final String[] includeGoalConfiguration,
      @RequestParam(value = "includeGoalSystemInfo", required = false, defaultValue = "")
          final String[] includeGoalSystemInfo,
      @RequestParam(value = "includeBugs", required = false, defaultValue = "false")
          final String includeBugs,
      @RequestParam(value = "includeExemptions", required = false, defaultValue = "false")
          final String includeExemptions,
      @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false) final String tenant,
      HttpServletRequest request,
      HttpServletResponse response); }
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) { 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>(); 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); @RequestMapping( value = "", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) ResponseEntity<Collection<Space>> getAllSpaces(
      @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false)
          String tenant); @RequestMapping( value = "default", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) ResponseEntity<Space> getDefaultSpace(
      @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false)
          String tenant); @RequestMapping( value = "search", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) 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); @RequestMapping(value = "/{token:.+}", method = RequestMethod.OPTIONS) ResponseEntity<Space> isSpaceExisting(
      @PathVariable String token,
      @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false)
          String tenant); @RequestMapping(value = "/{token:.+}", method = RequestMethod.GET) ResponseEntity<Space> getSpace(
      @PathVariable String token,
      @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false)
          String tenant); @RequestMapping( value = "", method = RequestMethod.POST, consumes = {"application/json;charset=UTF-8"}, produces = {"application/json;charset=UTF-8"}) ResponseEntity<Space> createSpace(
      @RequestBody Space space,
      @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false)
          String tenant); @RequestMapping( value = "/{token:.+}", method = RequestMethod.PUT, consumes = {"application/json;charset=UTF-8"}, produces = {"application/json;charset=UTF-8"}) ResponseEntity<Space> modifySpace(
      @PathVariable String token,
      @RequestBody Space new_space,
      @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false)
          String tenant); @RequestMapping(value = "/{token:.+}", method = RequestMethod.POST) ResponseEntity<Space> cleanSpace(
      @PathVariable String token,
      @RequestParam(value = "clean", required = true) Boolean clean,
      @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false)
          String tenant); @RequestMapping(value = "/{token:.+}", method = RequestMethod.DELETE) ResponseEntity<Space> deleteSpace(
      @PathVariable String token,
      @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false)
          String tenant); @RequestMapping(value = "/{token:.+}/apps", method = RequestMethod.GET) void getApplications(
      @PathVariable String token,
      @RequestParam(value = "includeSpaceProperties", required = false, defaultValue = "")
          final String[] includeSpaceProperties,
      @RequestParam(value = "includeGoalConfiguration", required = false, defaultValue = "")
          final String[] includeGoalConfiguration,
      @RequestParam(value = "includeGoalSystemInfo", required = false, defaultValue = "")
          final String[] includeGoalSystemInfo,
      @RequestParam(value = "includeBugs", required = false, defaultValue = "false")
          final String includeBugs,
      @RequestParam(value = "includeExemptions", required = false, defaultValue = "false")
          final String includeExemptions,
      @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false) final String tenant,
      HttpServletRequest request,
      HttpServletResponse response);  }