Line data Source code
1 : /* 2 : This file is part of TALER 3 : Copyright (C) 2024 Taler Systems SA 4 : 5 : TALER is free software; you can redistribute it and/or modify it under the 6 : terms of the GNU General Public License as published by the Free Software 7 : Foundation; either version 3, or (at your option) any later version. 8 : 9 : TALER is distributed in the hope that it will be useful, but WITHOUT ANY 10 : WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 : A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 : 13 : You should have received a copy of the GNU General Public License along with 14 : TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 : */ 16 : #include "platform.h" 17 : #include <gnunet/gnunet_util_lib.h> 18 : #include <gnunet/gnunet_json_lib.h> 19 : #include <jansson.h> 20 : #include <microhttpd.h> 21 : #include <pthread.h> 22 : #include "taler_json_lib.h" 23 : #include "taler_mhd_lib.h" 24 : #include "taler-auditor-httpd.h" 25 : #include "taler-auditor-httpd_delete_generic.h" 26 : 27 : 28 : MHD_RESULT 29 0 : TAH_delete_handler_generic ( 30 : struct TAH_RequestHandler *rh, 31 : struct MHD_Connection *connection, 32 : void **connection_cls, 33 : const char *upload_data, 34 : size_t *upload_data_size, 35 : const char *const args[]) 36 : { 37 : enum GNUNET_DB_QueryStatus qs; 38 : unsigned long long row_id; 39 : char dummy; 40 : 41 : (void) connection_cls; 42 0 : if (GNUNET_SYSERR == 43 0 : TAH_plugin->preflight (TAH_plugin->cls)) 44 : { 45 0 : GNUNET_break (0); 46 0 : return TALER_MHD_reply_with_error (connection, 47 : MHD_HTTP_INTERNAL_SERVER_ERROR, 48 : TALER_EC_GENERIC_DB_SETUP_FAILED, 49 : NULL); 50 : } 51 : 52 0 : if ((NULL == args[1]) || 53 0 : (1 != sscanf (args[1], 54 : "%llu%c", 55 : &row_id, 56 : &dummy))) 57 : { 58 0 : GNUNET_break_op (0); 59 0 : return TALER_MHD_reply_with_error (connection, 60 : MHD_HTTP_BAD_REQUEST, 61 : TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, 62 : "no row id specified"); 63 : } 64 : 65 : /* execute transaction */ 66 0 : qs = TAH_plugin->delete_generic (TAH_plugin->cls, 67 : rh->table, 68 : row_id); 69 0 : switch (qs) 70 : { 71 0 : case GNUNET_DB_STATUS_HARD_ERROR: 72 0 : GNUNET_break (0); 73 0 : return TALER_MHD_reply_with_error (connection, 74 : MHD_HTTP_INTERNAL_SERVER_ERROR, 75 : TALER_EC_GENERIC_DB_STORE_FAILED, 76 : "db store failed"); 77 0 : case GNUNET_DB_STATUS_SOFT_ERROR: 78 0 : GNUNET_break (0); 79 0 : return TALER_MHD_reply_with_error (connection, 80 : MHD_HTTP_INTERNAL_SERVER_ERROR, 81 : TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, 82 : "unexpected serialization problem"); 83 0 : case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: 84 0 : return TALER_MHD_reply_with_error (connection, 85 : MHD_HTTP_NOT_FOUND, 86 : TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, 87 : "no delete executed"); 88 0 : case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: 89 0 : return TALER_MHD_reply_static (connection, 90 : MHD_HTTP_NO_CONTENT, 91 : NULL, 92 : NULL, 93 : 0); 94 : } 95 0 : GNUNET_break (0); 96 0 : return MHD_NO; 97 : }