コード例 #1
0
  @RequestMapping(value = "/resource/available/{field}", method = RequestMethod.GET)
  @ResponseBody
  public Set<String> availableField(@PathVariable String field, @RequestParam String term) {
    Set<String> strings = new TreeSet<>();

    switch (field) {
      case "name":
        List<Content> contents = cmsLiteService.getAllContents();
        for (Content content : contents) {
          if (startsWith(content.getName(), term)) {
            strings.add(content.getName());
          }
        }
        break;
      case "language":
        for (Locale locale : getAvailableLocales()) {
          if (startsWithIgnoreCase(locale.getDisplayLanguage(), term)) {
            strings.add(locale.getDisplayLanguage());
          }
        }
        break;
      default:
    }

    return strings;
  }
コード例 #2
0
  @RequestMapping(value = "/resource", method = RequestMethod.GET)
  @ResponseBody
  public Resources getContents(GridSettings settings) {
    List<Content> contents = cmsLiteService.getAllContents();
    List<ResourceDto> resourceDtos = ResourceFilter.filter(settings, contents);

    Collections.sort(resourceDtos, new ResourceComparator(settings));

    return new Resources(settings, resourceDtos);
  }
コード例 #3
0
  @RequestMapping(value = "/resource/all/languages", method = RequestMethod.GET)
  @ResponseBody
  public Set<String> getAllLanguages() throws ContentNotFoundException {
    List<Content> contents = cmsLiteService.getAllContents();
    Set<String> strings = new TreeSet<>();

    for (Content content : contents) {
      strings.add(content.getLanguage());
    }

    return strings;
  }