예제 #1
0
  @PreAuthorize("hasPermission(#boardId, 'BOARD', 'ADMIN')")
  @RequestMapping(value = "/{filterId}/conditions/{fieldId}", method = RequestMethod.DELETE)
  public @ResponseBody void deleteFilterField(
      @PathVariable String boardId, @PathVariable String filterId, @PathVariable String fieldId)
      throws Exception {

    ObjectContentManager ocm = ocmFactory.getOcm();
    try {
      String path = String.format(URI.FILTER_CONDITION_URI, boardId, filterId, fieldId);
      ocm.getSession().removeItem(path);
      ocm.save();
      this.cacheInvalidationManager.invalidate(BoardController.BOARD, boardId);
    } finally {
      ocm.logout();
    }
  }
예제 #2
0
  @PreAuthorize("hasPermission(#boardId, 'BOARD', 'ADMIN')")
  @RequestMapping(value = "", method = RequestMethod.POST)
  public @ResponseBody Filter createFilter(@PathVariable String boardId, @RequestBody Filter filter)
      throws Exception {
    if (filter.getPath() != null) {
      logger.warn("Attempt to update filter using POST");
      throw new Exception("Attempt to Update Filter using POST. Use PUT instead");
    }

    ObjectContentManager ocm = ocmFactory.getOcm();
    try {
      listTools.ensurePresence(String.format(URI.BOARD_URI, boardId), "filters", ocm.getSession());
      String newId = IdentifierTools.getIdFromNamedModelClass(filter);
      filter.setPath(String.format(URI.FILTER_URI, boardId, newId.toString()));
      ocm.insert(filter);
      ocm.save();
      this.cacheInvalidationManager.invalidate(BoardController.BOARD, boardId);
    } finally {
      ocm.logout();
    }
    return filter;
  }
예제 #3
0
  @PreAuthorize("hasPermission(#boardId, 'BOARD', 'ADMIN')")
  @RequestMapping(value = "/{filterId}/conditions", method = RequestMethod.POST)
  public @ResponseBody Condition saveFilterField(
      @PathVariable String boardId,
      @PathVariable String filterId,
      @RequestBody Condition filterField)
      throws Exception {

    ObjectContentManager ocm = ocmFactory.getOcm();
    try {
      listTools.ensurePresence(
          String.format(URI.FILTER_URI, boardId, filterId), "conditions", ocm.getSession());
      filterField.setPath(
          String.format(URI.FILTER_CONDITION_URI, boardId, filterId, filterField.getFieldName()));
      ocm.insert(filterField);
      ocm.save();
      this.cacheInvalidationManager.invalidate(BoardController.BOARD, boardId);
    } finally {
      ocm.logout();
    }
    return filterField;
  }
예제 #4
0
  @PreAuthorize("hasPermission(#boardId, 'BOARD', 'ADMIN')")
  @RequestMapping(value = "/{filterId}", method = RequestMethod.DELETE)
  public @ResponseBody void deleteFilter(
      @PathVariable String boardId, @PathVariable String filterId) throws Exception {

    if (StringUtils.isBlank(filterId)) {
      return;
    }

    ObjectContentManager ocm = ocmFactory.getOcm();
    try {
      Node node = ocm.getSession().getNode(String.format(URI.FILTER_URI, boardId, filterId));

      if (node == null) {
        throw new ResourceNotFoundException();
      }

      node.remove();
      ocm.save();
      this.cacheInvalidationManager.invalidate(BoardController.BOARD, boardId);
    } finally {
      ocm.logout();
    }
  }