class SecretsResource {

  @Path("{secretId}")
  @Timed @ExceptionMetered
  @DELETE
  public Response deleteSecret(@Auth User user, @PathParam("secretId") LongParam secretId) {
    Optional<Secret> secret = secretController.getSecretById(secretId.get());
    if (!secret.isPresent()) {
      logger.info("User '{}' tried deleting a secret which was not found (id={})", user,
          secretId.get());
      throw new NotFoundException("Secret not found.");
    }

    logger.info("User '{}' deleting secret id={}, name='{}'", user, secretId,
        secret.get().getName());

    // Get the groups for this secret, so they can be restored manually if necessary
    Set<String> groups =
        aclDAOReadOnly.getGroupsFor(secret.get()).stream().map(Group::getName).collect(toSet());

    secretDAOReadWrite.deleteSecretsByName(secret.get().getName());

    // Record the deletion
    Map<String, String> extraInfo = new HashMap<>();
    extraInfo.put("groups", groups.toString());
    extraInfo.put("current version", secret.get().getVersion().toString());
    auditLog.recordEvent(
        new Event(Instant.now(), EventTag.SECRET_DELETE, user.getName(), secret.get().getName(),
            extraInfo));
    return Response.noContent().build();
  }

  @SuppressWarnings("unused") @Inject public  SecretsResource(SecretController secretController, AclDAOFactory aclDAOFactory,
      SecretDAOFactory secretDAOFactory, AuditLog auditLog);
  @VisibleForTesting  SecretsResource(SecretController secretController, AclDAO aclDAOReadOnly,
      SecretDAO secretDAOReadWrite, AuditLog auditLog);

}