private int sub() throws Exception {
    Array<P2<String, Option<UUID>>> parse = outvoicePaidClient.parse(outvoicePaidClient.get());

    int i = 0;
    for (P2<String, Option<UUID>> p : parse) {
      RegistrationsSqlMapper.Registration registration;
      try (Connection c = dataSource.getConnection()) {
        c.setAutoCommit(false);

        Option<UUID> apiClientRef = p._2();
        if (apiClientRef.isNone()) continue;

        Option<UUID> registrationId =
            registrationsSqlMapper.invoiceReferenceToRegistrationId(c, apiClientRef.some());
        if (registrationId.isNone()) continue;

        registration = registrationsSqlMapper.one(c, registrationId.some()).some();
      }

      if (registration.tuple.state != RegistrationState.INVOICING) continue;

      markAsPaidService.markAsPaid(registration.id);
      i++;
    }
    return i;
  }
  @POST
  @Path("/{registrationId}")
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.APPLICATION_JSON)
  public Response postUpdate(
      @Context HttpServletRequest request, @PathParam("registrationId") UUID id, String body)
      throws Exception {
    authService.guardAuthenticatedUser(request);
    Either<String, RegistrationsUpdate> map =
        ArgoUtils.parseEither(body)
            .right()
            .map(x -> x.getNode("tuple"))
            .right()
            .bind(RegistrationsRestService::registrationsUpdate);

    if (map.isLeft()) return Response.serverError().build();
    RegistrationsUpdate ru = map.right().value();

    try (Connection c = dataSource.getConnection()) {
      c.setAutoCommit(false);
      if (!registrationsSqlMapper.one(c, id).isSome())
        return Response.status(Status.NOT_FOUND).build();
      registrationsSqlMapper.update(
          c, id, ru.billingCompany, ru.badge, ru.dietaryRequirements, ru.bundle);
      c.commit();
    }
    return Response.ok().build();
  }
 private F<UUID, IO<Option<RegistrationsSqlMapper.Registration>>> ioify(Connection c) {
   return registrationId ->
       () -> {
         try {
           return registrationsSqlMapper.one(c, registrationId);
         } catch (SQLException e) {
           throw new IOException(e);
         }
       };
 }
 @GET
 @Path("/{registrationId}")
 @Produces(MediaType.APPLICATION_JSON)
 public Response getRegistration(
     @Context HttpServletRequest request, @PathParam("registrationId") UUID id) {
   authService.guardAuthenticatedUser(request);
   try {
     try (Connection c = dataSource.getConnection()) {
       return registrationsSqlMapper
           .one(c, id)
           .map(RegistrationsRestService::json)
           .map(ArgoUtils::format)
           .map(Response::ok)
           .orSome(Response.status(Status.NOT_FOUND))
           .build();
     }
   } catch (SQLException e) {
     e.printStackTrace();
     return Response.serverError().build();
   }
 }