Пример #1
0
  @PreAuthorize("hasPermission(#boardId, 'BOARD', 'READ,WRITE,ADMIN')")
  @RequestMapping(value = "", method = RequestMethod.GET)
  public @ResponseBody Map<String, String> listFilters(@PathVariable String boardId)
      throws Exception {

    Session session = ocmFactory.getOcm().getSession();
    Map<String, String> result = null;
    try {
      result = listTools.list(String.format(URI.FILTER_URI, boardId, ""), "name", session);
    } finally {
      session.logout();
    }
    return result;
  }
Пример #2
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();
    }
  }
Пример #3
0
  @PreAuthorize("hasPermission(#boardId, 'BOARD', 'READ,WRITE,ADMIN')")
  @RequestMapping(value = "/{filterId}", method = RequestMethod.GET)
  public @ResponseBody Filter getFilter(@PathVariable String boardId, @PathVariable String filterId)
      throws Exception {

    ObjectContentManager ocm = ocmFactory.getOcm();
    Filter filter = null;
    try {
      filter =
          (Filter) ocm.getObject(Filter.class, String.format(URI.FILTER_URI, boardId, filterId));
      if (filter == null) {
        throw new ResourceNotFoundException();
      }
    } finally {
      ocm.logout();
    }
    return filter;
  }
Пример #4
0
  @PreAuthorize("hasPermission(#boardId, 'BOARD', 'READ,WRITE,ADMIN')")
  @RequestMapping(value = "/{filterId}/execute", method = RequestMethod.GET)
  public @ResponseBody Collection<Card> executeFilter(
      @PathVariable String boardId, @PathVariable String filterId) throws Exception {

    ObjectContentManager ocm = ocmFactory.getOcm();
    Collection<Card> cards = null;

    try {
      cards = listTools.query(boardId, null, filterId, ocm);

      for (Card card : cards) {
        card.setFields(this.cardTools.getFieldsForCard(card, "full", ocm));
      }
    } finally {
      ocm.logout();
    }
    return cards;
  }
Пример #5
0
  @PreAuthorize("hasPermission(#boardId, 'BOARD', 'ADMIN')")
  @RequestMapping(value = "/{filterId}", method = RequestMethod.PUT)
  public @ResponseBody Filter updateFilter(
      @PathVariable String boardId, @PathVariable String filterId, @RequestBody Filter filter)
      throws Exception {

    if (filter.getPath() == null) {
      filter.setPath(String.format(URI.FILTER_URI, boardId, filterId));
    }

    ObjectContentManager ocm = ocmFactory.getOcm();
    try {
      ocm.update(filter);
      ocm.save();
      this.cacheInvalidationManager.invalidate(BoardController.BOARD, boardId);
    } finally {
      ocm.logout();
    }

    return filter;
  }
Пример #6
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;
  }
Пример #7
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;
  }
Пример #8
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();
    }
  }