public RangerTagResourceMap preCreateTagResourceMapByIds(Long tagId, Long resourceId)
      throws Exception {
    RangerTagResourceMap existing =
        tagStore.getTagResourceMapForTagAndResourceId(tagId, resourceId);

    if (existing != null) {
      throw new Exception(
          "Attempt to create existing association between resourceId="
              + resourceId
              + " and tagId="
              + tagId);
    }

    RangerServiceResource existingServiceResource = tagStore.getServiceResource(resourceId);

    if (existingServiceResource == null) {
      throw new Exception("No resource found for id=" + resourceId);
    }

    RangerTag existingTag = tagStore.getTag(tagId);

    if (existingTag == null) {
      throw new Exception("No tag found for id=" + tagId);
    }

    RangerTagResourceMap newTagResourceMap = new RangerTagResourceMap();
    newTagResourceMap.setResourceId(resourceId);
    newTagResourceMap.setTagId(tagId);

    return newTagResourceMap;
  }
  public RangerTagResourceMap preDeleteTagResourceMapByIds(Long tagId, Long resourceId)
      throws Exception {
    RangerTagResourceMap existing =
        tagStore.getTagResourceMapForTagAndResourceId(tagId, resourceId);

    if (existing == null) {
      throw new Exception(
          "Attempt to delete nonexistent association between resourceId="
              + resourceId
              + " and tagId="
              + tagId);
    }

    return existing;
  }