- Main Page
- Data Structures
- Files

- File List
- Globals

# samples/jsdelete.c

Go to the documentation of this file.

    00001 /*
    00002  * Copyright (C) 2007 JasperSoft http://www.jaspersoft.com
    00003  *
    00004  * This program is free software; you can redistribute it and/or modify
    00005  * it under the terms of the GNU General Public License as published by
    00006  * the Free Software Foundation; either version 2 of the License, or
    00007  * (at your option) any later version.
    00008  *
    00009  * This program is distributed WITHOUT ANY WARRANTY; and without the
    00010  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00011  * See the GNU General Public License for more details.
    00012  *
    00013  * You should have received a copy of the GNU General Public License
    00014  * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
    00015  * or write to:
    00016  *
    00017  * Free Software Foundation, Inc.,
    00018  * 59 Temple Place - Suite 330,
    00019  * Boston, MA  USA  02111-1307
    00020  */
    00021
    00030 #include <jasperserver.h>
    00031
    00032 const char server[] = "http://127.0.0.1:8080/jasperserver/services/repository";
    00033
    00040 void delete_resource(char *uri)
    00041 {
    00042       jasperserver_request_t *request = NULL;
    00043       jasperserver_server_t *jasperServer = NULL;
    00044       jasperserver_resource_descriptor_t *res = NULL;
    00045       jasperserver_operation_result_t *operationResult = NULL;
    00046
    00047       // Create a new structure of type jasperserver_server_t to save the
    00048       // server url and credentials.
    00049       jasperServer = jasperserver_server_new();
    00050       jasperserver_string_cset(jasperServer->url, server);
    00051       jasperserver_string_cset(jasperServer->username, "tomcat");
    00052       jasperserver_string_cset(jasperServer->password, "tomcat");
    00053
    00054       // Create a new structure of type jasperserver_request_t to store
    00055       // the request information like the resource to list
    00056       request = jasperserver_request_new();
    00057
    00058       //Creating and populating a new resource_descriptor...
    00059       res = jasperserver_resource_descriptor_new();
    00060       request->resource = res;
    00061       jasperserver_string_cset(res->uriString, uri);
    00062
    00063       // Call the web service
    00064       operationResult = jasperserver_ws_delete(jasperServer, request);
    00065
    00066       if (operationResult->returnCode == 0)
    00067       {
    00068          printf("Server version: %s, Return code: '%d', Return message '%s'\n", JS_CSTR( operationResult->version),  operationResult->returnCode, JS_CSTR( operationResult->returnMessage ));
    00069          printf("Deleted resource: %s\n\n", JS_CSTR( request->resource->uriString));
    00070          fflush( stdout );
    00071       }
    00072       else
    00073       {
    00074           //printf("Error executing the service: %d (%s)", operationResult->returnCode, JS_UTFSTR(operationResult->returnMessage) );
    00075           printf("Error executing the service: %d (%s)", operationResult->returnCode, JS_UTFSTR(operationResult->returnMessage) );
    00076       }
    00077
    00078       jasperserver_server_free( jasperServer );
    00079       jasperserver_request_free( request );
    00080       jasperserver_operation_result_free( operationResult );
    00081
    00082 }
    00083
    00084
    00085 int main(int argc, char **argv)
    00086 {
    00087    char *uri = NULL;
    00088    printf("JasperServer list sample (C) 2007 JasperSoft Corp.!\n");
    00089
    00090    if (argc > 1)
    00091    {
    00092      uri = argv[1];
    00093      delete_resource(uri);
    00094    }
    00095    else
    00096    {
    00097      printf("Please specify the URI to delete.\n\n");
    00098    }
    00099
    00100   return 0;
    00101 }