class PrivCreatePrivacyGroup implements JsonRpcMethod {

  @Override
  public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
    LOG.trace("Executing {}", RpcMethod.PRIV_CREATE_PRIVACY_GROUP.getMethodName());

    final CreatePrivacyGroupParameter parameter =
        requestContext.getRequiredParameter(0, CreatePrivacyGroupParameter.class);

    LOG.trace(
        "Creating a privacy group with name {} and description {}",
        parameter.getName(),
        parameter.getDescription());

    final PrivacyGroup response;
    try {
      response =
          privacyController.createPrivacyGroup(
              parameter.getAddresses(),
              parameter.getName(),
              parameter.getDescription(),
              enclavePublicKeyProvider.getEnclaveKey(requestContext.getUser()));
    } catch (Exception e) {
      LOG.error("Failed to create privacy group", e);
      return new JsonRpcErrorResponse(
          requestContext.getRequest().getId(),
          JsonRpcEnclaveErrorConverter.convertEnclaveInvalidReason(e.getMessage()));
    }
    return new JsonRpcSuccessResponse(
        requestContext.getRequest().getId(), response.getPrivacyGroupId());
  }

  public  PrivCreatePrivacyGroup(
      final PrivacyController privacyController,
      final EnclavePublicKeyProvider enclavePublicKeyProvider);

}