class SecretContentDAO {

  public long createSecretContent(long secretId, String encryptedContent, String hmac,
      String creator, Map<String, String> metadata, long expiry, long now) {
    SecretsContentRecord r = dslContext.newRecord(SECRETS_CONTENT);

    String jsonMetadata;
    try {
      jsonMetadata = mapper.writeValueAsString(metadata);
    } catch (JsonProcessingException e) {
      // Serialization of a Map<String, String> can never fail.
      throw Throwables.propagate(e);
    }

    long generatedId = rowHmacGenerator.getNextLongSecure();
    String rowHmac = rowHmacGenerator.computeRowHmac(
        SECRETS_CONTENT.getName(), List.of(encryptedContent, jsonMetadata, generatedId));

    r.setId(generatedId);
    r.setSecretid(secretId);
    r.setEncryptedContent(encryptedContent);
    r.setContentHmac(hmac);
    r.setCreatedby(creator);
    r.setCreatedat(now);
    r.setUpdatedby(creator);
    r.setUpdatedat(now);
    r.setMetadata(jsonMetadata);
    r.setExpiry(expiry);
    r.setRowHmac(rowHmac);
    r.store();

    pruneOldContents(secretId);

    return r.getId();
  }

  private  SecretContentDAO(DSLContext dslContext, ObjectMapper mapper,
      SecretContentMapper secretContentMapper, RowHmacGenerator rowHmacGenerator,
      KeywhizConfig config);

}