public void preUpdateServiceResourceByGuid(String guid, RangerServiceResource resource)
      throws Exception {
    if (StringUtils.isBlank(resource.getServiceName())
        || MapUtils.isEmpty(resource.getResourceElements())) {
      throw new Exception("No serviceName or resource in RangerServiceResource");
    }

    RangerServiceResource existing = tagStore.getServiceResourceByGuid(guid);
    if (existing == null) {
      throw new Exception("Attempt to update nonexistent resource, guid=" + guid);
    }

    RangerServiceResourceSignature serializer = new RangerServiceResourceSignature(resource);

    resource.setId(existing.getId());
    resource.setGuid(guid);
    resource.setResourceSignature(serializer.getSignature());
  }
  public RangerServiceResource preCreateServiceResource(RangerServiceResource resource)
      throws Exception {
    RangerServiceResource ret = null;

    if (StringUtils.isBlank(resource.getServiceName())
        || MapUtils.isEmpty(resource.getResourceElements())) {
      throw new Exception("No serviceName or resource in RangerServiceResource");
    }

    String guid = resource.getGuid();
    if (!StringUtils.isBlank(guid)) {
      ret = tagStore.getServiceResourceByGuid(guid);
    }

    RangerServiceResourceSignature serializer = new RangerServiceResourceSignature(resource);

    resource.setResourceSignature(serializer.getSignature());

    return ret;
  }