Changeset 962


Ignore:
Timestamp:
Oct 21, 2020, 6:31:09 PM (3 years ago)
Author:
djay
Message:

Update OGC API - Processes documentation and implementation, providing a browsable User Interface to Processes.

Location:
trunk
Files:
13 added
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/kernel/configuration.rst

    r950 r962  
    450450 * ``header_parameters``: the parameters list client applications can send as header
    451451 * ``version``: the Open API Specification version
    452    
     452 * ``license_name``: the license name for the service
     453 * ``license_url``: the license URL
     454 * ``full_html_support``: set it to true to activate support of the
     455   Accept header to choose between text/html or application/json
     456   format 
     457 * ``partial_html_support``: set it to true in case you have the
     458   display service from the `open-api directory
     459   <http://zoo-project.org/trac/browser/trunk/zoo-project/zoo-services/utils/open-api/cgi-env//cgi-env>`__
     460   and you want to aknowledge the text/html format in links
     461 * ``wsUrl``: the WebSocket URL to subscribe client to redis
     462 * ``publisherUrl``: the URL used to publish status updates
     463
    453464For any links and paths ``/A`` defined, you will have a corresponding
    454465``[/A]`` and ``[A]`` sections. In the ``[/A]`` section you will define
     
    494505 * ``[conformTo]``: referring to links list of the requirements classes the server implements and conforms to
    495506
     507
     508In case you have set ``partial_html_support`` or
     509``partial_html_support`` set to true, then you can add a corresponding
     510``[A.html]`` section providing the link informations. Also, it means
     511that you are willing to let the client choose in between
     512application/json and text/html format by providing the corresponding
     513Accept header in its request, when ``full_html_support`` is set to
     514true or by using the ``.html`` extension in the URL, in case
     515``partial_html_support`` was set true. Also, the user interface
     516provided in the `open-api directory
     517<http://zoo-project.org/trac/browser/trunk/zoo-project/zoo-services/utils/open-api/cgi-env//cgi-env>`__
     518will let the client goes untill the execution of a job. In case you
     519want this functionality to be working correctly we invite you to use a
     520``.htaccess`` equivalent to the one provided `here
     521<http://zoo-project.org/trac/browser/trunk/zoo-project/zoo-services/utils/open-api/server/.htacess>`__. Also
     522the WebSocket can be started using websocketd in combinaison with the
     523`subscriber.py
     524<http://zoo-project.org/trac/browser/trunk/zoo-project/zoo-services/utils/open-api/server/subscriber.py>`__
     525script, finally you will need to add the `publish.py
     526<http://zoo-project.org/trac/browser/trunk/zoo-project/zoo-services/utils/open-api/server/publish.py>`__
     527script in the cgi-bin directory of your web server.
     528
    496529For more information on how to interact with this WPS REST Binding, please refer
    497530to this `page
  • trunk/zoo-project/HISTORY.txt

    r961 r962  
    11Version 1.8.0-dev
     2  * Update OGC API - Processes documentation
     3  * Add open-api directory in utils services containing a reddis
     4  subscription example, the HTML UI and the display service using
     5  Cheetah templating system
     6  * Update the oas.cfg file to reflect new api definition
     7  * Include basic microdata in the HTML home page
     8  * Add HTML support for basic interractions with OGC API - Processes
     9  including execution of service from the service-desc link
     10  * OGC API - Processes added support for syncrhonous Execute requests
     11  * Reuse service_callback in OGC API - Processes when subscriber
     12  object is provided in the JSON request
     13  * OGC API - Processes implementation as available on 2020-10-19
    214  * Produce value string only when memory=load for Python support.
    315  * Make local files uris usable when cache is used
    4   * Make GDAL/prilfe service usable in case memory=protect
     16  * Make GDAL/profile service usable in case memory=protect
    517  * Add Dockerfile and docker-compose environment with pgbouncer, see #177
    618  * Add documentation on how to use asyncrhonous execution using the Javascript
  • trunk/zoo-project/zoo-kernel/Makefile.in

    r952 r962  
    4545
    4646service_callback.o: service_callback.c
    47         g++ -fPIC ${XML2CFLAGS} ${GDAL_CFLAGS} ${JSON_CFLAGS} ${CFLAGS} -c service_callback.c
     47        gcc -fPIC ${XML2CFLAGS} ${GDAL_CFLAGS} ${JSON_CFLAGS} ${CFLAGS} -c service_callback.c
    4848
    4949request_parser.o: request_parser.c request_parser.h
  • trunk/zoo-project/zoo-kernel/configure.ac

    r953 r962  
    8585                [], [AC_MSG_ERROR([could not find function in json-c library])])
    8686        CPPFLAGS="$CPPFLAGS_SAVE"
    87         JSON_FILE="service_json.o"
     87        JSON_FILE="service_json.o service_callback.o"
    8888        JSON_ENABLED="-DJSON"
    8989        if test "x$CALLBACK_ACTIVATED" == "xyes"
    9090        then
    91                 CALLBACK_FILE="service_callback.o"
     91                CALLBACK_FILE=""
    9292                CALLBACK_USE="-DUSE_CALLBACK"
    9393        fi
  • trunk/zoo-project/zoo-kernel/oas.cfg

    r950 r962  
    11[openapi]
    2 rootUrl=https://demo.mapmint.com/wps3/
     2use_content=false
     3rootUrl=https://myserver/ogc-api
    34links=/,/api,/conformance,/processes
    4 paths=/root,/api,/conformance,/processes,/processes/{id},/processes/{id}/jobs,/processes/{id}/jobs/{jobID},/processes/{id}/jobs/{jobID}/result
     5paths=/root,/api,/conformance,/processes,/processes/{id},/processes/{id}/jobs,/processes/{id}/jobs/{jobID},/processes/{id}/jobs/{jobID}/results
    56parameters=id,jobID,resultID
    6 header_parameters=oas-header1,oas-header2
    7 version=3.0.1
    8 
    9 [oas-header1]
    10 in=header
    11 name=Prefer
    12 type=string
    13 required=false
    14 enum=respond-async
    15 
    16 [oas-header2]
    17 in=header
    18 name=Prefer
    19 type=string
    20 required=false
    21 enum=return=representation,return=minimal
     7version=3.0.2
     8license_name=OGC license
     9license_url=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/LICENSE
     10full_html_support=false
     11partial_html_support=true
     12wsUrl=wss://demo.mapmint.com:4430/
     13publisherUrl=http://127.0.0.1/cgi-bin3/publish.py?jobid=
    2214
    2315[/]
     
    3224tags=Home
    3325tags_description=
    34 schema=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/schemas/root.yaml
     26schema=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/responses/LandingPage.yaml
     27
     28[/index.html]
     29rel=alternate
     30type=text/html
    3531
    3632[/api]
    37 rel=service
     33rel=service-desc
    3834type=application/openapi+json;version=3.0
    3935title=the API definition
     36
     37[/api.html]
     38rel=service-doc
     39type=text/hml
     40
     41[api.html]
     42href=https://demo.mapmint.com/swagger-ui/ogc-api-processes/
    4043
    4144[api]
     
    5558method=get
    5659title=information about standards that this API conforms to
    57 abstract==list all requirements classes specified in a standard (e.g., WPS REST/JSON Binding Core) that the server conforms to
     60abstract=list all requirements classes specified in a standard (e.g., WPS REST/JSON Binding Core) that the server conforms to
    5861tags=Conformance
    5962tags_description=
    60 schema=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/schemas/req-classes.yaml
     63schema=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/responses/ConformanceDeclaration.yaml
     64
     65[/conformance.html]
     66rel=alternate
     67type=text/hml
    6168
    6269[/processes]
     
    7178tags=GetCapabilities
    7279tags_description=
    73 schema=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/schemas/processCollection.yaml
     80schema=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/responses/ProcessList.yaml
     81
     82[/processes.html]
     83rel=alternate
     84type=text/hml
    7485
    7586[processes/{id}]
     
    7990tags=ProcessDescription
    8091tags_description=
    81 schema=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/schemas/process.yaml
     92schema=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/responses/ProcessDescription.yaml
     93ecode=404
    8294parameters=/components/parameters/id
    8395
     
    95107tags=JobList
    96108tags_description=
    97 schema=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/schemas/jobCollection.yaml
     109schema=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/responses/JobList.yaml
    98110parameters=/components/parameters/id
     111ecode=404,500
    99112method_1=post
    100113title_1=execute a job
     
    102115tags_1=Execute Endpoint
    103116tags_description_1=
    104 schema_1=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/schemas/result.yaml
    105 parameters_1=/components/parameters/id,/components/parameters/oas-header1
     117schema_1=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/responses/ExecuteSync.yaml
     118parameters_1=/components/parameters/id
     119ecode_1=400,404,500
     120eschema_1=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/responses/ExecuteAsync.yaml
     121ep=,/components/parameters/oas-header1
    106122
    107123[requestBody]
     
    116132
    117133[processes/{id}/jobs/{jobID}]
     134length=2
    118135method=get
    119136title=The status of a job.
     
    121138tags=GetStatus
    122139tags_description=
    123 schema=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/schemas/statusInfo.yaml
     140schema=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/responses/Status.yaml
    124141parameters=/components/parameters/id,/components/parameters/jobID
    125 
    126 [/processes/{id}/jobs/{jobID}/result]
     142method_1=delete
     143title_1=Cancel a job
     144abstract_1=Cancel the job execution.
     145tags_1=Dismiss
     146tags_description_1=Cencel a job execution
     147schema_1=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/responses/Status.yaml
     148parameters_1=/components/parameters/id,/components/parameters/jobID
     149ecode_1=404,500
     150
     151
     152[/processes/{id}/jobs/{jobID}/results]
    127153rel=canonical
    128154type=application/json
    129155title=Get Result
    130156
    131 [processes/{id}/jobs/{jobID}/result]
     157[processes/{id}/jobs/{jobID}/results]
    132158method=get
    133159title=The result of a job execution.
     
    135161tags=GetResult
    136162tags_description=
    137 schema=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/schemas/result.yaml
     163schema=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/responses/Results.yaml
    138164parameters=/components/parameters/id,/components/parameters/jobID
     165ecode=404,500
    139166ep=,/components/parameters/oas-header2
    140167
     
    151178tags_description=
    152179schema=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/schemas/valueType.yaml
    153 parameters=/components/parameters/id,/components/parameters/jobID,/components/parameters/resultID,/components/parameters/oas-header2
     180parameters=/components/parameters/id,/components/parameters/jobID,/components/parameters/resultID
     181ep=,/components/parameters/oas-header2
    154182
    155183
     
    184212required=false
    185213
    186 [conformTo]
    187 rootUrl=http://www.opengis.net/spec/WPS/2.0/req/service/binding/rest-json/
     214[conformsTo]
     215rootUrl=http://www.opengis.net/spec/ogcapi-processes/1.0/conf/
     216rootUrl0=http://www.opengis.net/spec/WPS/2.0/req/service/binding/rest-json/
    188217link=core
    189218link_1=oas30
    190219link_2=json
    191 length=3
     220link_3=job-list
     221link_4=dismiss
     222link_5=callback
     223length=6
    192224
    193225[exception]
    194226abstract=Exception
    195227type=application/json
    196 schema=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/schemas/exception.yaml
     228schema=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/responses/NotFound.yaml
     229default_schema=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/responses/ServerError.yaml
     230
     231[responses]
     232length=5
     233code=404
     234schema=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/responses/NotFound.yaml
     235type=application/json
     236title=NotFound
     237code_1=500
     238schema_1=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/responses/ServerError.yaml
     239type_1=application/json
     240title_1=ServerError
     241code_2=400
     242schema_2=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/responses/InvalidParameter.yaml
     243type_2=appliction/json
     244title_2=InvalidParameter
     245code_3=405
     246schema_3=https://github.com/opengeospatial/wps-rest-binding/blob/master/core/openapi/responses/NotAllowed.yaml
     247type_3=appliction/json
     248title_3=NotAllowed
     249code_4=406
     250schema_4=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/responses/NotSupported.yaml
     251type_4=appliction/json
     252title_4=NotSupported
     253
     254[callbacks]
     255length=3
     256state=jobSuccess
     257uri=successUri
     258schema=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/schemas/result.yaml
     259type=application/json
     260title=Results received successfully
     261state_1=jobInProgress
     262uri_1=inProgressUri
     263schema_1=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/schemas/statusInfo.yaml
     264type_1=application/json
     265title_1=Results received successfully
     266state_2=jobFailed
     267uri_2=failedUrii
     268schema_2=https://raw.githubusercontent.com/opengeospatial/wps-rest-binding/master/core/openapi/schemas/exception.yaml
     269type_2=application/json
     270title_2=Exception received successfully
     271
     272[links_title]
     273self=View this document in JSON.
     274alternate=View the alternative version in HTML.
     275conformance=View the specifications that the link’s context conforms to.
     276service-desc=View the service description.
     277service-doc=View service documentation.
     278processes=View the list of processes the API offers.
     279results=View the results of a process.
     280status=View the current status of a job execution.
     281execute=View the execution endpoint of a process.
     282
     283[provider_alt]
     284addressDeliveryPoint=streetAddress
     285addressCity=addressLocality
     286addressAdministrativeArea=addressRegion
     287addressPostalCode=postalCode
     288addressCountry=addressCountry
     289addressElectronicMailAddress=email
     290phoneVoice=telephone
     291phoneFacsimile=faxNumber
     292hoursOfService=hoursAvailable
     293contactInstructions=contactOption
     294
  • trunk/zoo-project/zoo-kernel/otbZooWatcher.cxx

    r937 r962  
    4545    {
    4646      int progressPercent = static_cast<int>(m_Process->GetProgress() * 100);
    47       updateStatus(m_Conf,progressPercent,m_Comment.c_str());
     47      if(progressPercent>iCounter){
     48        updateStatus(m_Conf,progressPercent,m_Comment.c_str());
     49        iCounter=progressPercent;
     50      }
    4851    }
    4952}
     
    5659  m_TimeProbe.Start();
    5760#endif
     61  iCounter=-1;
    5862}
    5963
  • trunk/zoo-project/zoo-kernel/otbZooWatcher.h

    r579 r962  
    8787  maps* m_Conf;
    8888
     89  /** Counter */
     90  int iCounter;
     91
    8992};
    9093
  • trunk/zoo-project/zoo-kernel/request_parser.c

    r957 r962  
    317317                    if (strncasecmp (tmpx2, "http://", 7) != 0 &&
    318318                        strncasecmp (tmpx2, "ftp://", 6) != 0 &&
    319                         strncasecmp (tmpx2, "https://", 8) != 0)
     319                        strncasecmp (tmpx2, "https://", 8) != 0 &&
     320                        strncasecmp (tmpx2, "file://", 7) != 0)
    320321                      {
    321322                        char emsg[1024];
  • trunk/zoo-project/zoo-kernel/response_print.c

    r956 r962  
    27192719  }
    27202720  if(res==SERVICE_FAILED){
    2721     map *lenv;
    2722     lenv=getMapFromMaps(m,"lenv","message");
    2723     char *tmp0;
    2724     if(lenv!=NULL){
    2725       tmp0=(char*)malloc((strlen(lenv->value)+strlen(_("Unable to run the Service. The message returned back by the Service was the following: "))+1)*sizeof(char));
    2726       sprintf(tmp0,_("Unable to run the Service. The message returned back by the Service was the following: %s"),lenv->value);
    2727     }
    2728     else{
    2729       tmp0=(char*)malloc((strlen(_("Unable to run the Service. No more information was returned back by the Service."))+1)*sizeof(char));
    2730       sprintf(tmp0,"%s",_("Unable to run the Service. No more information was returned back by the Service."));
    2731     }
     2721    char* tmp0=produceErrorMessage(m);
    27322722    errorException(m,tmp0,"InternalError",NULL);
    27332723    free(tmp0);
  • trunk/zoo-project/zoo-kernel/server_internal.c

    r961 r962  
    952952      free(res);
    953953    }
    954   else
    955     addToMap(statusInfo,"Status","Failed"); 
     954  else{
     955    addToMap(statusInfo,"Status","Failed");
     956    addToMap(statusInfo,"NotFound",pid);
     957  }
    956958  free(fbkpid);
    957959}
     
    992994void runGetStatus(maps* conf,char* pid,char* req){
    993995  map* r_inputs = getMapFromMaps (conf, "main", "tmpPath");
     996  map* e_type = getMapFromMaps (conf, "lenv", "executionType");
    994997  char *sid=getStatusId(conf,pid);
    995998  if(sid==NULL){
    996     errorException (conf, _("The JobID from the request does not match any of the Jobs running on this server"),
    997                     "NoSuchJob", pid);
     999    if(e_type==NULL || strncasecmp(e_type->value,"json",4)!=0)
     1000      errorException (conf, _("The JobID from the request does not match any of the Jobs running on this server"),
     1001                      "NoSuchJob", pid);
     1002    else{
     1003      setMapInMaps(conf,"lenv","error","true");
     1004      setMapInMaps(conf,"lenv","code","NoSuchJob");
     1005      setMapInMaps(conf,"lenv","message",_("The JobID from the request does not match any of the Jobs running on this server"));
     1006    }
    9981007  }else{
    9991008    map* statusInfo=createMap("JobID",pid);
    1000     if(isRunning(conf,pid)>0){         
     1009    if(isRunning(conf,pid)>0){
    10011010      if(strncasecmp(req,"GetResult",strlen(req))==0){
    1002         errorException (conf, _("The result for the requested JobID has not yet been generated. The service is currently running."),
    1003                         "ResultNotReady", pid);
     1011        if(e_type==NULL || strncasecmp(e_type->value,"json",4)!=0)
     1012          errorException (conf, _("The result for the requested JobID has not yet been generated. The service is currently running."),
     1013                          "ResultNotReady", pid);
     1014        else{
     1015          setMapInMaps(conf,"lenv","error","true");
     1016          setMapInMaps(conf,"lenv","code","ResultNotReady");
     1017          setMapInMaps(conf,"lenv","message",_("The result for the requested JobID has not yet been generated. The service is currently running."));
     1018        }
    10041019        return;
    10051020      }
    1006       else
     1021      else{
    10071022        if(strncasecmp(req,"GetStatus",strlen(req))==0){
    10081023          addToMap(statusInfo,"Status","Running");
     1024          setMapInMaps(conf,"lenv","status","Running");
    10091025          char* tmpStr=_getStatus(conf,pid);
    10101026          if(tmpStr!=NULL && strncmp(tmpStr,"-1",2)!=0){
     
    10151031            addToMap(statusInfo,"PercentCompleted",tmpStr1);
    10161032            addToMap(statusInfo,"Message",tmpStr0);
     1033            setMapInMaps(conf,"lenv","PercentCompleted",tmpStr1);
     1034            setMapInMaps(conf,"lenv","Message",tmpStr0);
    10171035            free(tmpStr0);
    10181036            free(tmpStr1);
    10191037          }
    10201038        }
     1039      }
    10211040    }
    10221041    else{
     
    10431062        if(strncasecmp(req,"GetStatus",strlen(req))==0){
    10441063          readFinalRes(conf,pid,statusInfo);
     1064          if(e_type==NULL || strncasecmp(e_type->value,"json",4)==0){
     1065            map* pmStatus=getMap(statusInfo,"status");     
     1066            if(pmStatus!=NULL)
     1067              setMapInMaps(conf,"lenv","status",pmStatus->value);   
     1068          }
    10451069          char* tmpStr=_getStatus(conf,pid);
    10461070          if(tmpStr!=NULL && strncmp(tmpStr,"-1",2)!=0){
     
    10511075            addToMap(statusInfo,"PercentCompleted",tmpStr1);
    10521076            addToMap(statusInfo,"Message",tmpStr0);
     1077            setMapInMaps(conf,"lenv","PercentCompleted",tmpStr1);
     1078            setMapInMaps(conf,"lenv","Message",tmpStr0);
    10531079            free(tmpStr0);
    10541080            free(tmpStr1);
     
    10571083    }
    10581084    free(sid);
    1059     printStatusInfo(conf,statusInfo,req);
     1085    if(e_type==NULL || strncasecmp(e_type->value,"json",4)!=0)
     1086      printStatusInfo(conf,statusInfo,req);
     1087    else
     1088      setMapInMaps(conf,"lenv","error","false");
    10601089    freeMap(&statusInfo);
    10611090    free(statusInfo);
     
    10721101void runDismiss(maps* conf,char* pid){
    10731102  map* r_inputs = getMapFromMaps (conf, "main", "tmpPath");
     1103  map* e_type = getMapFromMaps (conf, "lenv", "executionType");
    10741104  char *sid=getStatusId(conf,pid);
    10751105  if(sid==NULL){
    1076     errorException (conf, _("The JobID from the request does not match any of the Jobs running on this server"),
    1077                     "NoSuchJob", pid);
     1106    if(e_type==NULL || strncasecmp(e_type->value,"json",4)!=0)
     1107      errorException (conf, _("The JobID from the request does not match any of the Jobs running on this server"),
     1108                      "NoSuchJob", pid);
     1109    else{
     1110      setMapInMaps(conf,"lenv","error","true");
     1111      setMapInMaps(conf,"lenv","code","NoSuchJob");
     1112      setMapInMaps(conf,"lenv","message",_("The JobID from the request does not match any of the Jobs running on this server"));
     1113    }
     1114    return;
    10781115  }else{
    10791116    // We should send the Dismiss request to the target host if it differs
     
    11151152          sprintf(fileName,"%s/%s",r_inputs->value,dp->d_name);
    11161153          if(zUnlink(fileName)!=0){
    1117             errorException (conf,
    1118                             _("The job cannot be removed, a file cannot be removed"),
    1119                             "NoApplicableCode", NULL);
     1154            if(e_type==NULL || strncasecmp(e_type->value,"json",4)!=0)
     1155              errorException (conf,
     1156                              _("The job cannot be removed, a file cannot be removed"),
     1157                              "NoApplicableCode", NULL);
     1158            else{
     1159                    setMapInMaps(conf,"lenv","error","true");
     1160                    setMapInMaps(conf,"lenv","code","NoApplicableCode");
     1161                    setMapInMaps(conf,"lenv","message",_("The job cannot be removed, a file cannot be removed"));
     1162            }
    11201163            return;
    11211164          }
    1122         }
    1123       }
    1124     }
     1165         
     1166        }
     1167      }
     1168    }
     1169    map* pmStatusFile=getMapFromMaps(conf,"lenv","file.statusFile");
     1170    if(pmStatusFile!=NULL && zUnlink(pmStatusFile->value)!=0){
     1171        if(e_type==NULL || strncasecmp(e_type->value,"json",4)!=0)
     1172          errorException (conf,
     1173                          _("The job cannot be removed, a file cannot be removed"),
     1174                          "NoApplicableCode", NULL);
     1175        else{
     1176          setMapInMaps(conf,"lenv","error","true");
     1177                    setMapInMaps(conf,"lenv","code","NoApplicableCode");
     1178                    setMapInMaps(conf,"lenv","message",_("The job cannot be removed, a file cannot be removed"));
     1179        }
     1180        return;
     1181      }
    11251182#ifdef RELY_ON_DB
    11261183    removeService(conf,pid);
    11271184#endif
    1128     /* No need to call 7_1 when an execution is dismissed.
    1129       fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    1130       invokeCallback(conf,NULL,NULL,7,1);
    1131       fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    1132     */
    1133     map* statusInfo=createMap("JobID",pid);
    1134     addToMap(statusInfo,"Status","Dismissed");
    1135     printStatusInfo(conf,statusInfo,"Dismiss");
    1136     free(statusInfo);
     1185    if(e_type==NULL || strncasecmp(e_type->value,"json",4)!=0){
     1186      /* No need to call 7_1 when an execution is dismissed.
     1187         fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     1188         invokeCallback(conf,NULL,NULL,7,1);
     1189         fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     1190      */
     1191      map* statusInfo=createMap("JobID",pid);
     1192      addToMap(statusInfo,"Status","Dismissed");
     1193      printStatusInfo(conf,statusInfo,"Dismiss");
     1194      free(statusInfo);
     1195    }else{
     1196      setMapInMaps(conf,"lenv","error","false");
     1197    }
    11371198  }
    11381199  return;
     
    12491310}
    12501311
     1312/**
     1313 * Create a string containing the basic error message.
     1314 *
     1315 * @param pmConf the main configuration maps pointer
     1316 * @return a new char* containing the error message (ressource should be freed)
     1317 */
     1318char* produceErrorMessage(maps* pmConf){
     1319  char *pacTmp;
     1320  map *pmLenv=getMapFromMaps(pmConf,"lenv","message");
     1321  if(pmLenv!=NULL){
     1322    pacTmp=(char*)malloc((strlen(pmLenv->value)+strlen(_("Unable to run the Service. The message returned back by the Service was the following: "))+1)*sizeof(char));
     1323    sprintf(pacTmp,_("Unable to run the Service. The message returned back by the Service was the following: %s"),pmLenv->value);
     1324  }
     1325  else{
     1326    pacTmp=(char*)malloc((strlen(_("Unable to run the Service. No more information was returned back by the Service."))+1)*sizeof(char));
     1327    sprintf(pacTmp,"%s",_("Unable to run the Service. No more information was returned back by the Service."));
     1328  }
     1329  return pacTmp;
     1330}
     1331
    12511332#ifdef WIN32
    12521333/**
  • trunk/zoo-project/zoo-kernel/server_internal.h

    r921 r962  
    6060  void dumpMapsValuesToFiles(maps**,maps**);
    6161  void runDismiss(maps*,char*);
     62  int isRunning(maps*,char*);
    6263  void runGetStatus(maps*,char*,char*);
     64  void readFinalRes(maps*,char*,map*);
    6365
    6466  int isValidLang(maps*,const char*);
     
    6769  int readServiceFile (maps *, char *, service **, char *);
    6870  int createRegistry (maps*,registry **,char *);
     71  char* produceErrorMessage(maps*);
    6972
    7073  int zoo_path_compare(char* path1, char* path2);
  • trunk/zoo-project/zoo-kernel/service.h

    r957 r962  
    185185 */
    186186#define SERVICE_FAILED 4
     187/**
     188 * The global dismissed status for a service
     189 */
     190#define SERVICE_DISMISSED 5
    187191
    188192/**
  • trunk/zoo-project/zoo-kernel/service_callback.c

    r955 r962  
    2727 */
    2828
    29 #include "service_json.h"
    3029#include "service_internal_ms.h"
    31 #include "sqlapi.h"
    3230#include <pthread.h>
    3331#include <libxml/tree.h>
     
    4240
    4341#include "service_callback.h"
     42#include "service_json.h"
     43#include "sqlapi.h"
     44#include <ulinet.h>
     45
    4446
    4547#ifdef __cplusplus
     
    6668   */
    6769  int cStep=0;
     70  /**
     71   * Maximum value of PercentCompleted
     72   */
     73  int maxProgress=0;
    6874  /**
    6975   * Is there any ongoing HTTP request
     
    112118    return false;
    113119  }
    114 
     120  /**
     121   * Practically invoke the callback, meaning sending the HTTP POST request.
     122   *
     123   * @param args local_params containing all the variables required
     124   */
     125  void* _invokeBasicCallback(void* args){
     126#ifdef CALLBACK_DEBUG
     127    fprintf(stderr,"************************* From thread %d %s %d: REQUEST CONFIGURE (%s)\n",pthread_self(),__FILE__,__LINE__,arg->url->value);
     128    fflush(stderr);
     129#endif
     130    local_params* arg=(local_params*)args;
     131    if(arg->state<cStep){
     132#ifdef CALLBACK_DEBUG
     133      fprintf(stderr,"************************* From thread %d %s %d: REQUEST CANCELLED (%s) EXIT!\n",pthread_self(),__FILE__,__LINE__,arg->url->value);
     134      fflush(stderr);
     135#endif
     136      freeMaps(&arg->conf);
     137      free(arg->conf);
     138      freeMap(&arg->url);
     139      free(arg->url);
     140      pthread_exit(NULL);
     141      return NULL;
     142    }
     143    HINTERNET hInternet,res1;
     144    const struct tm *tm;
     145    size_t len;
     146    char *tmp1;
     147    map *tmpStatus;
     148    map* pmTmp=getMapFromMaps(arg->conf,"lenv","status");
     149    hInternet=InternetOpen("ZooWPSClient\0",
     150                           INTERNET_OPEN_TYPE_PRECONFIG,
     151                           NULL,NULL, 0);
     152    if(!CHECK_INET_HANDLE(hInternet)){
     153      InternetCloseHandle (&hInternet);
     154      return NULL;
     155    }
     156    const char* jsonStr=json_object_to_json_string_ext(arg->res,JSON_C_TO_STRING_PLAIN);
     157    while( arg->state != SERVICE_SUCCEEDED && arg->state != SERVICE_FAILED && isOngoing>0 ){
     158      zSleep(100);
     159    }
     160    if(arg->state==SERVICE_STARTED && pmTmp!=NULL){
     161      if(maxProgress<=atoi(pmTmp->value)){
     162        maxProgress=atoi(pmTmp->value);
     163      }else{
     164#ifdef CALLBACK_DEBUG
     165        fprintf(stderr,"************************* From thread %d %s %d: REQUEST CANCELLED (%s) EXIT!\n",pthread_self(),__FILE__,__LINE__,arg->url->value);
     166        fflush(stderr);
     167#endif
     168        freeMaps(&arg->conf);
     169        free(arg->conf);
     170        freeMap(&arg->url);
     171        free(arg->url);
     172        pthread_exit(NULL);
     173        return NULL;
     174      }
     175    }else
     176      maxProgress=101;
     177    isOngoing=1;
     178    maps* tmpConf=createMaps("main");
     179    tmpConf->content=createMap("memory","load");
     180
     181    hInternet.waitingRequests[0] = zStrdup(arg->url->value);
     182    res1 = InternetOpenUrl (&hInternet,
     183                            hInternet.waitingRequests[0],
     184                            (char*)jsonStr, strlen(jsonStr),
     185                            INTERNET_FLAG_NO_CACHE_WRITE,
     186                            0,tmpConf);
     187    AddHeaderEntries(&hInternet,arg->conf);
     188    AddMissingHeaderEntry(&hInternet.ihandle[hInternet.nb-1],"Content-Type","application/json");
     189#ifdef CALLBACK_DEBUG
     190    curl_easy_setopt(hInternet.ihandle[hInternet.nb-1].handle, CURLOPT_VERBOSE, 1);
     191#endif
     192    if(hInternet.ihandle[hInternet.nb-1].header!=NULL)
     193      curl_easy_setopt(hInternet.ihandle[hInternet.nb-1].handle,CURLOPT_HTTPHEADER,hInternet.ihandle[hInternet.nb-1].header);
     194    processDownloads(&hInternet);
     195    freeMaps(&tmpConf);
     196    free(tmpConf);
     197#ifdef CALLBACK_DEBUG
     198    char *tmp = (char *) malloc ((hInternet.ihandle[0].nDataLen + 1)
     199                                 * sizeof (char));
     200    if (tmp == NULL)
     201      {
     202        setMapInMaps(arg->conf,"lenv","message",_("Unable to allocate memory"));
     203        setMapInMaps(arg->conf,"lenv","code","InternalError");
     204        return NULL;
     205      }
     206    size_t bRead;
     207    InternetReadFile (hInternet.ihandle[0],
     208                      (LPVOID) tmp,
     209                      hInternet.
     210                      ihandle[0].nDataLen,
     211                      &bRead);
     212    tmp[hInternet.ihandle[0].nDataLen] = 0;
     213    fprintf(stderr,"************************* From thread %d %s %d: REQUEST END \n%s",pthread_self(),__FILE__,__LINE__,tmp);
     214    fflush(stderr);
     215    free(tmp);
     216#endif
     217    json_object_put(arg->res);
     218    InternetCloseHandle(&hInternet);
     219    isOngoing=0;
     220    freeMaps(&arg->conf);
     221    free(arg->conf);
     222    freeMap(&arg->url);
     223    if(arg->url!=NULL)
     224      free(arg->url);
     225    pthread_exit(NULL);
     226  }
     227
     228  /**
     229   * Invoke the callback in case there is a [subscriber] section containing one
     230   * or more url parameter.
     231   *
     232   * @param conf the maps containing the main configuration file definitions
     233   * @param state the service state SERVICE_SUCCEEDED / STARTED / FAILED
     234   * @return bool true in case of success, false in other cases
     235   */
     236  bool invokeBasicCallback(maps* conf,int state){
     237    map* url=getMapFromMaps(conf,"subscriber","inProgressUri");
     238    if(state==SERVICE_SUCCEEDED)
     239      url=getMapFromMaps(conf,"subscriber","successUri");
     240    else
     241      if(state==SERVICE_FAILED)
     242        url=getMapFromMaps(conf,"subscriber","failedUri");
     243    if(url==NULL)
     244      return false;
     245    map* url0=createMap("url",url->value);
     246    map* sname=getMapFromMaps(conf,"lenv","identifier");
     247    if(sname!=NULL && isProhibited(conf,sname->value))
     248      return false;
     249    if(state<cStep)
     250      return true;
     251    if(cStep!=state || isOngoing==0){
     252      json_object *res=NULL;
     253      if(state==SERVICE_SUCCEEDED || state==SERVICE_FAILED){
     254        maps* pmsTmp=getMaps(conf,"lenv");
     255        setMapInMaps(conf,"lenv","no-write","true");
     256        map* pmTmp=getMapFromMaps(conf,"lenv","usid");
     257        if(pmTmp!=NULL){
     258          map* pmResponse=getMapFromMaps(conf,"lenv","jsonStr");
     259          res=parseJson(conf,pmResponse->value);
     260        }
     261      }else
     262        res=createStatus(conf,state);
     263      if(local_arguments==NULL)
     264        local_arguments=(local_params**)malloc(sizeof(local_params*));
     265      else
     266        local_arguments=(local_params**)realloc(local_arguments,(nbThreads+1)*sizeof(local_params*));
     267      local_arguments[nbThreads]=(local_params*)malloc(MAPS_SIZE+MAP_SIZE+sizeof(json_object*)+(2*sizeof(int)));       
     268      local_arguments[nbThreads]->conf=dupMaps(&conf);
     269      local_arguments[nbThreads]->url=url0;
     270      local_arguments[nbThreads]->res=res;
     271      local_arguments[nbThreads]->step=0;
     272      local_arguments[nbThreads]->state=state;
     273      cStep=state;
     274      if(myThreads==NULL)
     275        myThreads=(pthread_t*)malloc((nbThreads+1)*sizeof(pthread_t));
     276      else
     277        myThreads=(pthread_t*)realloc(myThreads,(nbThreads+1)*sizeof(pthread_t));
     278      if(pthread_create(&myThreads[nbThreads], NULL, _invokeBasicCallback, (void*)local_arguments[nbThreads])==-1){
     279        setMapInMaps(conf,"lenv","message",_("Unable to create a new thread"));
     280        return false;
     281      }
     282      nbThreads++;
     283    }
     284    return true;
     285  }
     286 
    115287  /**
    116288   * Practically invoke the callback, meaning sending the HTTP POST request.
     
    336508              map* tmpMap=getMapArray(curs->content,"value",ii);
    337509              char tmpStr[100];
    338               sprintf(tmpStr,"%d",strlen(tmpMap->value));
     510              sprintf(tmpStr,"%ld",strlen(tmpMap->value));
    339511              setMapArray(curs->content,"size",ii,tmpStr);
    340512              tmpMap=getMapArray(curs->content,"mimeType",ii);
     
    570742              jsStr=json_object_new_string(tmp2->value);
    571743              json_object_object_add(res2,"target_path",jsStr);
    572               json_object *res4=json_object_object_get(res1,tmp0->value);
    573               if(json_object_is_type(res4,json_type_null)){
    574                 json_object_object_add(res1,tmp0->value,res2);
    575               }else{
    576                 if(json_object_is_type(res4,json_type_object) && !json_object_is_type(res4, json_type_array)){
    577                   json_object *res3=json_object_new_array();
    578                   json_object_array_add(res3,json_object_get(res4));
    579                   json_object_array_add(res3,res2);
    580                   json_object_object_del(res1,tmp0->value);
    581                   json_object_object_add(res1,tmp0->value,res3);
    582                 }else
    583                   json_object_array_add(res4,res2);
     744              json_object *res4=NULL;
     745              if(json_object_object_get_ex(res1,tmp0->value,&res4)!=FALSE){
     746                if(json_object_is_type(res4,json_type_null)){
     747                  json_object_object_add(res1,tmp0->value,res2);
     748                }else{
     749                  if(json_object_is_type(res4,json_type_object) && !json_object_is_type(res4, json_type_array)){
     750                    json_object *res3=json_object_new_array();
     751                    json_object_array_add(res3,json_object_get(res4));
     752                    json_object_array_add(res3,res2);
     753                    json_object_object_del(res1,tmp0->value);
     754                    json_object_object_add(res1,tmp0->value,res3);
     755                  }else
     756                    json_object_array_add(res4,res2);
     757                }
    584758              }
    585759            }
     
    8661040   */
    8671041  void cleanupCallbackThreads(){
     1042    while( isOngoing>0 ){
     1043      zSleep(100);
     1044    }
    8681045    int i=0;
    8691046    for(i=0;i<nbThreads;i++){
  • trunk/zoo-project/zoo-kernel/service_callback.h

    r955 r962  
    3232#pragma once
    3333
    34 #include <ulinet.h>
    35 #include <stdio.h>
    36 #include <ctype.h>
    3734#include <service.h>
    3835
     
    4138#endif
    4239
     40  bool invokeBasicCallback(maps*,int);
    4341  bool invokeCallback(maps*,maps*,maps*,int,int);
    4442  void cleanupCallbackThreads();
  • trunk/zoo-project/zoo-kernel/service_internal.c

    r945 r962  
    412412    free(fbkpid);
    413413    char* stat=getStatusId(conf,lid);
    414     setMapInMaps(conf,"lenv","lid",stat);
     414    if(stat!=NULL)
     415      setMapInMaps(conf,"lenv","lid",stat);
    415416    removeShmLock(conf,1);
    416417    return NULL;
     
    470471      fflush(fstatus);
    471472      fclose(fstatus);
     473      invokeBasicCallback(conf,SERVICE_STARTED);
    472474    }
    473475    if(stat!=NULL){
  • trunk/zoo-project/zoo-kernel/service_internal_otb.c

    r647 r962  
    122122  map* tmp=NULL;
    123123  int res=-1;
     124  int saved_stdout = zDup (fileno (stdout));
     125  zDup2 (fileno (stderr), fileno (stdout));
    124126  std::vector<std::string> list = ApplicationRegistry::GetAvailableApplications();
    125127  if (list.size() == 0){
    126128    map* tmps=createMap("text","No OTB Application found.");
    127129    addToMap(tmps,"code","InternalError");
     130    zDup2 (saved_stdout, fileno (stdout));
     131    zClose(saved_stdout);
    128132    printExceptionReportResponse(m,tmps);
    129133    freeMap(&tmps);
     
    142146          map* tmps=createMap("text",tmpS);
    143147          addToMap(tmps,"code","InternalError");
     148          zDup2 (saved_stdout, fileno (stdout));
     149          zClose(saved_stdout);
    144150          printExceptionReportResponse(m,tmps);
    145151          freeMap(&tmps);
     
    460466          catch(std::exception& err){
    461467            setMapInMaps(m,"lenv","message",err.what());
     468            zDup2 (saved_stdout, fileno (stdout));
     469            zClose(saved_stdout);
    462470            return SERVICE_FAILED;
    463471           
     
    479487  }
    480488  m_WatcherList.clear();
    481 
     489  fflush(stdout);
     490  zDup2 (saved_stdout, fileno (stdout));
     491  zClose(saved_stdout);
    482492  return res;
    483493}
  • trunk/zoo-project/zoo-kernel/service_internal_python.c

    r961 r962  
    446446    Py_DECREF(name);
    447447    tmp=tmp->next;
    448   } 
     448  }
    449449  return (PyDictObject*) res;
    450450}
     
    572572    }
    573573    else{
    574       if(PyDict_GetItem(res,name)==NULL){
     574      if(PyDict_GetItem(res,name)==NULL && strlen(tmp->value)>0){
    575575        PyObject* value=PyString_FromString(tmp->value);
    576576        if(PyDict_SetItem(res,name,value)<0){
  • trunk/zoo-project/zoo-kernel/service_json.c

    r954 r962  
    22 * Author : Gérald FENOY
    33 *
    4  *  Copyright 2017-2019 GeoLabs SARL. All rights reserved.
     4 *  Copyright 2017-2020 GeoLabs SARL. All rights reserved.
    55 *
    66 * Permission is hereby granted, free of charge, to any person obtaining a copy
     
    223223      if(tmpMap1!=NULL){
    224224        json_object_object_add(prop2,"name",json_object_new_string(tmpMap1->value));
     225        char *tmp=(char*)malloc((strlen(tmpMap1->value)+35)*sizeof(char));
     226        sprintf(tmp,"http://www.w3.org/TR/xmlschema-2/#%s",tmpMap1->value);
     227        json_object_object_add(prop2,"reference",json_object_new_string(tmp));
     228        free(tmp);
    225229        json_object_object_add(prop1,"dataType",prop2);
    226230      }
     
    371375      tmpMap=getMap(in->content,"abstract");
    372376      if(tmpMap!=NULL)
    373         json_object_object_add(input,"abstract",json_object_new_string(tmpMap->value));
     377        json_object_object_add(input,"description",json_object_new_string(tmpMap->value));
    374378      if(strcmp(io,"input")==0){
    375379        tmpMap=getMap(in->content,"minOccurs");
    376380        if(tmpMap!=NULL)
    377           json_object_object_add(input,"minOccurs",json_object_new_string(tmpMap->value));
     381          json_object_object_add(input,"minOccurs",json_object_new_int(atoi(tmpMap->value)));
    378382        tmpMap=getMap(in->content,"maxOccurs");
    379         if(tmpMap!=NULL)
    380           json_object_object_add(input,"maxOccurs",json_object_new_string(tmpMap->value));
     383        if(tmpMap!=NULL){
     384          if(strncasecmp(tmpMap->value,"unbounded",9)==0)
     385            json_object_object_add(input,"maxOccurs",json_object_new_string(tmpMap->value));
     386          else
     387            json_object_object_add(input,"maxOccurs",json_object_new_int(atoi(tmpMap->value)));
     388        }
    381389      }
    382390      if(in->format!=NULL){
     
    439447    json_object* doc=(json_object*) doc0;
    440448    json_object* nc=(json_object*) nc0;
    441     json_object *res=json_object_new_object();
     449    json_object *res;
     450    if(doc!=NULL)
     451      res=json_object_new_object();
     452    else
     453      res=(json_object*) nc0;
     454     
    442455    map* tmpMap0=getMapFromMaps(m,"lenv","level");
    443456    char* rUrl=serv->name;
     
    486499      tmpMap=getMap(serv->content,"abstract");
    487500      if(tmpMap!=NULL){
    488         json_object_object_add(res,"abstract",json_object_new_string(tmpMap->value));
     501        json_object_object_add(res,"description",json_object_new_string(tmpMap->value));
    489502      }
    490503      tmpMap=getMap(serv->content,"processVersion");
     
    498511        else
    499512          json_object_object_add(res,"version",json_object_new_string(tmpMap->value));
    500       }
     513      }else
     514        json_object_object_add(res,"version",json_object_new_string("1.0.0"));
    501515      int limit=4;
    502516      int i=0;
     
    517531      json_object *res1=json_object_new_array();
    518532      json_object *res2=json_object_new_object();
    519       json_object_object_add(res2,"rel",json_object_new_string("canonical"));
     533      json_object *res3=json_object_new_object();
     534      map* pmTmp=getMapFromMaps(m,"lenv","requestType");
     535      if(pmTmp!=NULL && strncasecmp(pmTmp->value,"desc",4)==0)
     536        json_object_object_add(res2,"rel",json_object_new_string("process-desc"));
     537      else{
     538        json_object_object_add(res2,"rel",json_object_new_string("execute"));
     539        json_object_object_add(res3,"rel",json_object_new_string("alternate"));
     540        json_object_object_add(res3,"type",json_object_new_string("text/html"));
     541      }
    520542      json_object_object_add(res2,"type",json_object_new_string("application/json"));
    521543      json_object_object_add(res2,"title",json_object_new_string("Process Description"));
     
    525547      if(doc==NULL){
    526548        json_object_object_add(res2,"title",json_object_new_string("Execute End Point"));
     549        json_object_object_add(res3,"title",json_object_new_string("Execute End Point"));
    527550        char* tmpStr1=zStrdup(tmpStr);
    528551        tmpStr=(char*) realloc(tmpStr,(strlen(tmpStr)+6)*sizeof(char));
    529         sprintf(tmpStr,"%sjobs/",tmpStr1);
     552        sprintf(tmpStr,"%sjobs",tmpStr1);
    530553        free(tmpStr1);
     554        char* tmpStr3=(char*) malloc((strlen(tmpStr)+6)*sizeof(char));
     555        sprintf(tmpStr3,"%s.html",tmpStr);
     556        json_object_object_add(res3,"href",json_object_new_string(tmpStr3));
     557        free(tmpStr3);
    531558      }
    532559      json_object_object_add(res2,"href",json_object_new_string(tmpStr));
    533560      free(tmpStr);
    534561      json_object_array_add(res1,res2);
     562      tmpUrl=getMapFromMaps(m,"openapi","partial_html_support");
     563      if(tmpUrl!=NULL && strncasecmp(tmpUrl->value,"true",4)==0)
     564        json_object_array_add(res1,res3);
     565      else
     566        json_object_put(res3);
    535567      json_object_object_add(res,"links",res1);
    536568    }
     
    551583    if(doc!=NULL)
    552584      json_object_array_add(doc,res);
    553     else
    554       json_object_object_add(nc,"process",json_object_get(res));
    555 
    556585  }
    557586
     
    577606      if(strcmp(tmp->value,"OperationNotSupported")==0 ||
    578607         strcmp(tmp->value,"NoApplicableCode")==0)
    579         exceptionCode="501 Not Implemented";
     608        exceptionCode="500 Not Implemented";
    580609      else
    581610        if(strcmp(tmp->value,"MissingParameterValue")==0 ||
     
    586615          exceptionCode="400 Bad request";
    587616        else
    588           if(strcmp(tmp->value,"NotFound")==0)
     617          if(strcmp(tmp->value,"NotFound")==0 ||
     618             strcmp(tmp->value,"NoSuchProcess")==0 ||
     619             strcmp(tmp->value,"NoSuchJob")==0 ||
     620             strcmp(tmp->value,"ResultNotReady")==0)
    589621            exceptionCode="404 Not Found";
    590622          else
    591             exceptionCode="501 Internal Server Error";
     623            exceptionCode="500 Internal Server Error";
    592624      json_object_object_add(res,"code",json_object_new_string(tmp->value));
    593625    }
    594     else
    595       exceptionCode="501 Internal Server Error";
    596     printHeaders(m);
     626    else{
     627      exceptionCode="500 Internal Server Error";
     628      json_object_object_add(res,"code",json_object_new_string("NoApplicableCode"));
     629    }
     630    if(getMapFromMaps(m,"lenv","no-headers")==NULL)
     631      printHeaders(m);
    597632
    598633    tmp=getMapFromMaps(m,"lenv","status_code");
    599634    if(tmp!=NULL)
    600635      exceptionCode=tmp->value;
    601     if(m!=NULL){
    602       map *tmpSid=getMapFromMaps(m,"lenv","sid");
    603       if(tmpSid!=NULL){
    604         if( getpid()==atoi(tmpSid->value) ){
     636    if(getMapFromMaps(m,"lenv","no-headers")==NULL){
     637      if(m!=NULL){
     638        map *tmpSid=getMapFromMaps(m,"lenv","sid");
     639        if(tmpSid!=NULL){
     640          if( getpid()==atoi(tmpSid->value) ){
     641            printf("Status: %s\r\n\r\n",exceptionCode);
     642          }
     643        }
     644        else{
    605645          printf("Status: %s\r\n\r\n",exceptionCode);
    606646        }
    607       }
    608       else{
     647      }else{
    609648        printf("Status: %s\r\n\r\n",exceptionCode);
    610649      }
    611     }else{
    612       printf("Status: %s\r\n\r\n",exceptionCode);
    613650    }
    614651    tmp=getMap(s,"text");
     
    620657      json_object_object_add(res,"description",json_object_new_string(tmp->value));
    621658    const char* jsonStr=json_object_to_json_string_ext(res,JSON_C_TO_STRING_PLAIN);
     659    if(getMapFromMaps(m,"lenv","jsonStr")==NULL)
     660      setMapInMaps(m,"lenv","jsonStr",jsonStr);
     661    maps* pmsTmp=getMaps(m,"lenv");
    622662    printf(jsonStr);
    623663    if(m!=NULL)
     
    876916   * @param outputs the produced maps
    877917   */
    878   void parseJRequest(maps* conf, service* s,json_object* req,maps** inputs,maps** outputs){
     918  void parseJRequest(maps* conf, service* s,json_object* req, map* request_inputs, maps** inputs,maps** outputs){
    879919    elements* io=s->inputs;
    880920
     
    890930        parseJIO(conf,req,s->outputs,outputs,"outputs");
    891931      }
    892     }     
     932      json_io=NULL;
     933      if(json_object_object_get_ex(req,"mode",&json_io)!=FALSE){
     934        addToMap(request_inputs,"mode",json_object_get_string(json_io));
     935        setMapInMaps(conf,"request","mode",json_object_get_string(json_io));
     936      }
     937      json_io=NULL;
     938      if(json_object_object_get_ex(req,"response",&json_io)!=FALSE){
     939        addToMap(request_inputs,"response",json_object_get_string(json_io));
     940        setMapInMaps(conf,"request","response",json_object_get_string(json_io));
     941      }
     942      json_io=NULL;
     943      if(json_object_object_get_ex(req,"subscriber",&json_io)!=FALSE){
     944        maps* subscribers=createMaps("subscriber");
     945        json_object* json_subscriber=NULL;
     946        if(json_object_object_get_ex(json_io,"successUri",&json_subscriber)!=FALSE){
     947          subscribers->content=createMap("successUri",json_object_get_string(json_subscriber));
     948        }
     949        if(json_object_object_get_ex(json_io,"inProgressUri",&json_subscriber)!=FALSE){
     950          if(subscribers->content==NULL)
     951            subscribers->content=createMap("inProgressUri",json_object_get_string(json_subscriber));
     952          else
     953            addToMap(subscribers->content,"inProgressUri",json_object_get_string(json_subscriber));
     954        }
     955        if(json_object_object_get_ex(json_io,"failedUri",&json_subscriber)!=FALSE){
     956          if(subscribers->content==NULL)
     957            subscribers->content=createMap("failedUri",json_object_get_string(json_subscriber));
     958          else
     959            addToMap(subscribers->content,"failedUri",json_object_get_string(json_subscriber));
     960        }
     961        addMapsToMaps(&conf,subscribers);
     962        freeMaps(&subscribers);
     963        free(subscribers);
     964      }
     965    }
     966   
    893967  }
    894968
     
    9341008            if (jerr != json_tokener_success) {
    9351009              fprintf(stderr, "Error: %s\n", json_tokener_error_desc(jerr));
    936               return res;
     1010              return NULL;
    9371011            }
    9381012            if (tok->char_offset < slen){
    939               return res;
     1013              return NULL;
    9401014            }
    9411015            json_object_object_add(cjob,"infos",jobj);
     
    9511025    return res;
    9521026  }
    953 
     1027 
    9541028  /**
    9551029   * Print the result of an execution
     
    9581032   * @param s service pointer to metadata
    9591033   * @param result outputs of the service
    960    * @param res the status of executino SERVICE_FAILED/SERVICE_SUCCEEDED
     1034   * @param res the status of execution SERVICE_FAILED/SERVICE_SUCCEEDED
    9611035   * @return the JSON object pointer to the result
    9621036   */
    9631037  json_object* printJResult(maps* conf,service* s,maps* result,int res){
    964     printHeaders(conf);
    9651038    json_object* eres1=json_object_new_object();
     1039    if(res==SERVICE_FAILED){
     1040      char* pacTmp=produceErrorMessage(conf);
     1041      map* pamTmp=createMap("message",pacTmp);
     1042      free(pacTmp);
     1043      map* pmTmp=getMapFromMaps(conf,"lenv","code");
     1044      if(pmTmp!=NULL)
     1045        addToMap(pamTmp,"code",pmTmp->value);
     1046      printExceptionReportResponseJ(conf,pamTmp);
     1047      freeMap(&pamTmp);
     1048      free(pamTmp);
     1049      return NULL;
     1050    }
     1051    if(getMapFromMaps(conf,"lenv","no-headers")==NULL)
     1052      printHeaders(conf);
    9661053    json_object* eres=json_object_new_array();
    9671054    maps* resu=result;
     
    9701057      json_object* res1=json_object_new_object();
    9711058      json_object_object_add(res1,"id",json_object_new_string(resu->name));
    972       map* tmpMap=NULL;
     1059      map* tmpMap=getMap(resu->content,"mimeType");
     1060      json_object* res3=json_object_new_object();
     1061      if(tmpMap!=NULL)
     1062        json_object_object_add(res3,"mimeType",json_object_new_string(tmpMap->value));
    9731063      if((tmpMap=getMap(resu->content,"value"))!=NULL ||
    9741064         (getMap(resu->content,"generated_file"))!=NULL){
     
    9941084                return eres1;           
    9951085              }
     1086              json_object_object_add(res3,"encoding",json_object_new_string("utf-8"));
    9961087              json_object_object_add(res2,"inlineValue",jobj);
    997             }else
    998               json_object_object_add(res2,"inlineValue",json_object_new_string(tmpMap->value));
     1088            }else{
     1089              map* tmp1=getMapFromMaps(conf,"main","tmpPath");
     1090              map *gfile=getMap(resu->content,"generated_file");
     1091              if(gfile!=NULL){
     1092                gfile=getMap(resu->content,"expected_generated_file");
     1093                if(gfile==NULL){
     1094                  gfile=getMap(resu->content,"generated_file");
     1095                }
     1096                FILE* pfData=fopen(gfile->value,"rb");
     1097                if(pfData!=NULL){
     1098                  zStatStruct f_status;
     1099                  int s=zStat(gfile->value, &f_status);
     1100                  char* pcaTmp=(char*)malloc((f_status.st_size+1)*sizeof(char));
     1101                  fread(pcaTmp,1,f_status.st_size,pfData);
     1102                  pcaTmp[f_status.st_size]=0;       
     1103                  fclose(pfData);
     1104                  json_object_object_add(res2,"inlineValue",json_object_new_string(base64(pcaTmp,f_status.st_size)));
     1105                  json_object_object_add(res3,"encoding",json_object_new_string("base64"));
     1106                  free(pacTmp);
     1107                }
     1108              }else{
     1109                json_object_object_add(res3,"encoding",json_object_new_string("utf-8"));
     1110                json_object_object_add(res2,"inlineValue",json_object_new_string(tmpMap->value));
     1111              }
     1112            }
    9991113          }
    10001114          else{
     
    10981212        }
    10991213        json_object_object_add(res1,"value",res2);     
     1214        json_object_object_add(res1,"format",res3);     
    11001215        json_object_array_add(eres,res1);
    11011216      }
     
    11081223    map *cIdentifier = getMapFromMaps (conf, "lenv", "oIdentifier");
    11091224    map *sessId = getMapFromMaps (conf, "lenv", "usid");
    1110     char tmp[1024];
    1111     sprintf(tmp,"%s/%s_%s.json",
     1225    char *pacTmp=(char*)malloc((strlen(tmpPath->value)+strlen(cIdentifier->value)+strlen(sessId->value)+8)*sizeof(char));
     1226    sprintf(pacTmp,"%s/%s_%s.json",
    11121227            tmpPath->value,cIdentifier->value,sessId->value);
    1113     FILE* foutput=fopen(tmp,"w+");
    1114     if(foutput!=NULL){
    1115       fclose(foutput);
    1116       char tmpUrl[1024];
     1228    zStatStruct zsFStatus;
     1229    int iS=zStat(pacTmp, &zsFStatus);
     1230    if(iS==0 && zsFStatus.st_size>0){
    11171231      map* tmpPath1 = getMapFromMaps (conf, "main", "tmpUrl");
    1118       sprintf(tmpUrl,"%s/%s_%s.json",tmpPath1->value,
     1232      char* pacTmpUrl=(char*)malloc((strlen(tmpPath1->value)+strlen(cIdentifier->value)+strlen(sessId->value)+8)*sizeof(char));;
     1233      sprintf(pacTmpUrl,"%s/%s_%s.json",tmpPath1->value,
    11191234              cIdentifier->value,sessId->value);
    1120       setMapInMaps(conf,"headers","Location",tmpUrl);
    1121     }
     1235      if(getMapFromMaps(conf,"lenv","gs_location")==NULL)
     1236        setMapInMaps(conf,"headers","Location",pacTmpUrl);
     1237      free(pacTmpUrl);
     1238    }
     1239    free(pacTmp);
    11221240    if(res==3){
    1123       setMapInMaps(conf,"headers","Status","201 Created");
     1241      map* mode=getMapFromMaps(conf,"request","mode");
     1242      if(mode!=NULL && strncasecmp(mode->value,"async",5)==0)
     1243        setMapInMaps(conf,"headers","Status","201 Created");
     1244      else
     1245        setMapInMaps(conf,"headers","Status","200 Ok");
    11241246    }
    11251247    else{
    11261248      setMapInMaps(conf,"headers","Status","500 Issue running your service");
    11271249    }
    1128 
    11291250    return eres1;
    11301251  }
     
    11441265    map *cIdentifier = getMapFromMaps (conf, "lenv", "oIdentifier");
    11451266    map *sessId = getMapFromMaps (conf, "lenv", "usid");
     1267    if(sessId==NULL){
     1268      sessId = getMapFromMaps (conf, "lenv", "gs_usid");
     1269    }
    11461270    char *Url0=(char*) malloc((strlen(tmpPath->value)+
    11471271                               strlen(cIdentifier->value)+
     
    11531277            cIdentifier->value,
    11541278            sessId->value);
    1155     setMapInMaps(conf,"headers","Location",Url0);
     1279    if(getMapFromMaps(conf,"lenv","gs_location")==NULL)
     1280      setMapInMaps(conf,"headers","Location",Url0);
    11561281    json_object* val=json_object_new_object();
    1157     json_object_object_add(val,"Title",
     1282    json_object_object_add(val,"title",
    11581283                           json_object_new_string(_("Status location")));
     1284    json_object_object_add(val,"rel",
     1285                           json_object_new_string(_("status")));
     1286    json_object_object_add(val,"type",
     1287                           json_object_new_string(_("application/json")));
    11591288    json_object_object_add(val,"href",json_object_new_string(Url0));
    11601289    json_object_array_add(res,val);
     
    11641293                           strlen(cIdentifier->value)+strlen(sessId->value)+
    11651294                           25)*sizeof(char));
    1166       sprintf(Url0,"%s/processes/%s/jobs/%s/result",
     1295      sprintf(Url0,"%s/processes/%s/jobs/%s/results",
    11671296              tmpPath->value,
    11681297              cIdentifier->value,
    11691298              sessId->value);
    11701299      json_object* val1=json_object_new_object();
    1171       json_object_object_add(val1,"Title",
     1300      json_object_object_add(val1,"title",
    11721301                             json_object_new_string(_("Result location")));
     1302      json_object_object_add(val1,"rel",
     1303                             json_object_new_string(_("results")));
     1304      json_object_object_add(val1,"type",
     1305                             json_object_new_string(_("application/json")));
    11731306      json_object_object_add(val1,"href",json_object_new_string(Url0));
    11741307      json_object_array_add(res,val1);
     
    12041337      return NULL;
    12051338    }
    1206     free(tmp1);
    1207     tmp1=(char*) malloc((strlen(tmpPath->value)+
     1339    tmp1=(char*) realloc(tmp1,(strlen(tmpPath->value)+
    12081340                         strlen(cIdentifier->value)+
    1209                          strlen(sessId->value)+20)*sizeof(char));
     1341                         strlen(sessId->value)+21)*sizeof(char));
    12101342    int needResult=0;
    12111343    char *message, *rstatus;
     
    12141346            cIdentifier->value,
    12151347            sessId->value);
    1216    
    12171348    return tmp1;
    12181349  }
     1350
     1351  char* getResultPath(maps* conf,char* jobId){
     1352    map *tmpPath = getMapFromMaps (conf, "main", "tmpPath");
     1353    map *cIdentifier = getMapFromMaps (conf, "lenv", "oIdentifier");
     1354    char *pacUrl=(char*) malloc((strlen(tmpPath->value)+
     1355                                 strlen(cIdentifier->value)+
     1356                                 strlen(jobId)+8)*sizeof(char));
     1357    sprintf(pacUrl,"%s/%s_%s.json",tmpPath->value,
     1358            cIdentifier->value,jobId);
     1359    return pacUrl;
     1360  }
     1361
     1362  json_object* parseJson(maps* conf,char* myString){
     1363    json_object *pajObj = NULL;
     1364    enum json_tokener_error jerr;
     1365    struct json_tokener* tok=json_tokener_new();
     1366    int slen = 0;
     1367    do {
     1368      slen = strlen(myString);
     1369      pajObj = json_tokener_parse_ex(tok, myString, slen);
     1370    } while ((jerr = json_tokener_get_error(tok)) == json_tokener_continue);
     1371    if (jerr != json_tokener_success) {
     1372      setMapInMaps(conf,"lenv","message",json_tokener_error_desc(jerr));
     1373      fprintf(stderr, "Error: %s\n", json_tokener_error_desc(jerr));
     1374      return NULL;
     1375    }
     1376    if (tok->char_offset < slen){
     1377      return NULL;
     1378    }
     1379    return pajObj;
     1380  }
    12191381 
    1220   /**
    1221    * Create the status file
    1222    *
    1223    * @param conf the maps containing the settings of the main.cfg file
    1224    * @param status an integer (SERVICE_ACCEPTED,SERVICE_STARTED...)
    1225    * @return an integer (0 in case of success, 1 in case of failure)
    1226    */
    1227   int createStatusFile(maps* conf,int status){
     1382  json_object* json_readFile(maps* conf,char* filePath){
     1383    json_object *pajObj = NULL;
     1384    zStatStruct zsFStatus;
     1385    int iS=zStat(filePath, &zsFStatus);
     1386    if(iS==0 && zsFStatus.st_size>0){
     1387      FILE* cdat=fopen(filePath,"rb");
     1388      if(cdat!=NULL){
     1389        char* pacMyString=(char*)malloc((zsFStatus.st_size+1)*sizeof(char));
     1390        fread(pacMyString,1,zsFStatus.st_size,cdat);
     1391        pacMyString[zsFStatus.st_size]=0;
     1392        fclose(cdat);
     1393        pajObj=parseJson(conf,pacMyString);
     1394        free(pacMyString);
     1395      }
     1396      else
     1397        return NULL;
     1398    }else
     1399      return NULL;
     1400    return pajObj;
     1401  }
     1402 
     1403  json_object* createStatus(maps* conf,int status){
    12281404    int needResult=0;
    1229     const char *message, *rstatus;
    1230     char* tmp1=json_getStatusFilePath(conf);
     1405    const char *rstatus;
     1406    char *message;
    12311407    // Create statusInfo JSON object
    12321408    // cf. https://github.com/opengeospatial/wps-rest-binding/blob/master/core/
    12331409    //     openapi/schemas/statusInfo.yaml
    12341410    json_object* res=json_object_new_object();
    1235     json_object_object_add(res,"status",json_object_new_string("successful"));
    12361411    switch(status){
    12371412    case SERVICE_ACCEPTED:
     
    12441419      {
    12451420        message=_("ZOO-Kernel is currently running your service!");
     1421        map* pmStatus=getMapFromMaps(conf,"lenv","status");
     1422        if(pmStatus!=NULL)
     1423          setMapInMaps(conf,"lenv","PercentCompleted",pmStatus->value);
     1424        pmStatus=getMapFromMaps(conf,"lenv","message");
     1425        if(pmStatus!=NULL)
     1426          setMapInMaps(conf,"lenv","gs_message",pmStatus->value);
    12461427        rstatus="running";
    12471428        break;
     
    12571438        message=_("ZOO-Kernel successfully run your service!");
    12581439        rstatus="successful";
     1440        setMapInMaps(conf,"lenv","PercentCompleted","100");
    12591441        needResult=1;
    12601442        break;
    12611443      }
     1444    case SERVICE_DISMISSED:
     1445      {
     1446        message=_("ZOO-Kernel successfully dismissed your service!");
     1447        rstatus="dismissed";
     1448        needResult=1;
     1449        break;
     1450      }
    12621451    default:
    12631452      {
    1264         message=_("ZOO-Kernel failed to run your service!");
     1453        map* pmTmp=getMapFromMaps(conf,"lenv","force");
     1454        if(pmTmp==NULL || strncasecmp(pmTmp->value,"false",5)==0){
     1455          char* pacTmp=json_getStatusFilePath(conf);
     1456          json_object* pjoStatus=json_readFile(conf,pacTmp);
     1457          free(pacTmp);
     1458          if(pjoStatus!=NULL){
     1459            json_object* pjoMessage=NULL;
     1460            if(json_object_object_get_ex(pjoStatus,"message",&pjoMessage)!=FALSE){
     1461              message=(char*)json_object_get_string(pjoMessage);
     1462            }
     1463          }
     1464          // TODO: Error
     1465        }else{
     1466          map* mMap=getMapFromMaps(conf,"lenv","gs_message");
     1467          if(mMap!=NULL)
     1468            setMapInMaps(conf,"lenv","message",mMap->value);
     1469          message=produceErrorMessage(conf);
     1470          needResult=-1;
     1471        }
    12651472        rstatus="failed";
    12661473        break;
     
    12691476    setMapInMaps(conf,"lenv","message",message);
    12701477    setMapInMaps(conf,"lenv","status",rstatus);
    1271        
    1272     map* mess=getMapFromMaps(conf,"lenv","message");
    1273     if(mess!=NULL)
    1274       json_object_object_add(res,"message",json_object_new_string(mess->value));
    1275 
    1276     createStatusLinks(conf,needResult,res);
    1277    
     1478
     1479    map *sessId = getMapFromMaps (conf, "lenv", "usid");
     1480    if(sessId!=NULL){
     1481      sessId = getMapFromMaps (conf, "lenv", "gs_usid");
     1482      if(sessId==NULL)
     1483        sessId = getMapFromMaps (conf, "lenv", "usid");
     1484    }else
     1485      sessId = getMapFromMaps (conf, "lenv", "gs_usid");
     1486    if(sessId!=NULL)
     1487      json_object_object_add(res,"jobID",json_object_new_string(sessId->value));
     1488    json_object_object_add(res,"status",json_object_new_string(rstatus));
     1489    map* mMap=getMapFromMaps(conf,"lenv","gs_message");
     1490    if(mMap==NULL)
     1491      json_object_object_add(res,"message",json_object_new_string(message));
     1492    else{
     1493      json_object_object_add(res,"message",json_object_new_string(mMap->value));
     1494      if((mMap=getMapFromMaps(conf,"lenv","PercentCompleted"))!=NULL)
     1495        json_object_object_add(res,"progress",json_object_new_int(atoi(mMap->value)));
     1496    }
     1497    if(status!=SERVICE_DISMISSED)
     1498      createStatusLinks(conf,needResult,res);
     1499    else{
     1500      json_object* res1=json_object_new_array();
     1501      map *tmpPath = getMapFromMaps (conf, "openapi", "rootUrl");
     1502      map *cIdentifier = getMapFromMaps (conf, "lenv", "oIdentifier");
     1503      char *Url0=(char*) malloc((strlen(tmpPath->value)+
     1504                                 strlen(cIdentifier->value)+
     1505                                 17)*sizeof(char));
     1506      sprintf(Url0,"%s/processes/%s/jobs",           
     1507              tmpPath->value,
     1508              cIdentifier->value);
     1509      json_object* val=json_object_new_object();
     1510      json_object_object_add(val,"title",
     1511                             json_object_new_string(_("The job list for the current process")));
     1512      json_object_object_add(val,"rel",
     1513                             json_object_new_string(_("parent")));
     1514      json_object_object_add(val,"type",
     1515                             json_object_new_string(_("application/json")));
     1516      json_object_object_add(val,"href",json_object_new_string(Url0));
     1517      json_object_array_add(res1,val);
     1518      free(Url0);
     1519      json_object_object_add(res,"links",res1);
     1520    }
     1521    if(needResult<0)
     1522      free(message);
     1523    return res;
     1524  }
     1525 
     1526  /**
     1527   * Create the status file
     1528   *
     1529   * @param conf the maps containing the settings of the main.cfg file
     1530   * @param status an integer (SERVICE_ACCEPTED,SERVICE_STARTED...)
     1531   * @return an integer (0 in case of success, 1 in case of failure)
     1532   */
     1533  int createStatusFile(maps* conf,int status){
     1534    json_object* res=createStatus(conf,status);
     1535    char* tmp1=json_getStatusFilePath(conf);
    12781536    FILE* foutput1=fopen(tmp1,"w+");
    12791537    if(foutput1!=NULL){
     
    13031561    map* tmpMap=getMapFromMaps(conf,"lenv","gs_usid");
    13041562    if(tmpMap!=NULL){
    1305         char* tmpStr=_getStatus(conf,tmpMap->value);
    1306         if(tmpStr!=NULL && strncmp(tmpStr,"-1",2)!=0){
    1307           char *tmpStr1=zStrdup(tmpStr);
    1308           char *tmpStr0=zStrdup(strstr(tmpStr,"|")+1);
    1309           free(tmpStr);
    1310           tmpStr1[strlen(tmpStr1)-strlen(tmpStr0)-1]='\0';
    1311           setMapInMaps(conf,"lenv","PercentCompleted",tmpStr1);
    1312           setMapInMaps(conf,"lenv","gs_message",tmpStr0);
    1313           free(tmpStr0);
    1314           free(tmpStr1);
    1315         }
    1316       }
     1563      char* tmpStr=_getStatus(conf,tmpMap->value);
     1564      if(tmpStr!=NULL && strncmp(tmpStr,"-1",2)!=0){
     1565        char *tmpStr1=zStrdup(tmpStr);
     1566        char *tmpStr0=zStrdup(strstr(tmpStr,"|")+1);
     1567        free(tmpStr);
     1568        tmpStr1[strlen(tmpStr1)-strlen(tmpStr0)-1]='\0';
     1569        setMapInMaps(conf,"lenv","PercentCompleted",tmpStr1);
     1570        setMapInMaps(conf,"lenv","gs_message",tmpStr0);
     1571        free(tmpStr0);
     1572        free(tmpStr1);
     1573        return 0;
     1574      }else{
     1575         
     1576      }
     1577    }
    13171578  }
    13181579
     
    13711632
    13721633    json_object *res4=json_object_new_object();
    1373     tmpMap=getMapFromMaps(conf,"main","license_name");
     1634    tmpMap=getMapFromMaps(conf,"openapi","license_name");
    13741635    if(tmpMap!=NULL){
    13751636      json_object_object_add(res4,"name",json_object_new_string(tmpMap->value));
    1376       tmpMap=getMapFromMaps(conf,"main","license_url");
     1637      tmpMap=getMapFromMaps(conf,"openapi","license_url");
    13771638      if(tmpMap!=NULL){
    13781639        json_object_object_add(res4,"url",json_object_new_string(tmpMap->value));     
     
    13841645  }
    13851646
     1647  // addResponse(pmUseContent,cc3,vMap,tMap,"200","successful operation");
     1648  void addResponse(const map* useContent,json_object* res,const map* pmSchema,const map* pmType,const char* code,const char* msg){
     1649    json_object *cc=json_object_new_object();
     1650    if(pmSchema!=NULL)
     1651      json_object_object_add(cc,"$ref",json_object_new_string(pmSchema->value));
     1652    if(useContent!=NULL && strncasecmp(useContent->value,"true",4)!=0){
     1653        json_object_object_add(res,code,cc);
     1654    }else{
     1655        json_object *cc0=json_object_new_object();
     1656        if(pmSchema!=NULL)
     1657          json_object_object_add(cc0,"schema",cc);
     1658        json_object *cc1=json_object_new_object();
     1659        if(pmType!=NULL)
     1660          json_object_object_add(cc1,pmType->value,cc0);
     1661        else
     1662          json_object_object_add(cc1,"application/json",cc0);
     1663        json_object *cc2=json_object_new_object();
     1664        json_object_object_add(cc2,"content",cc1);
     1665        json_object_object_add(cc2,"description",json_object_new_string(msg));
     1666        json_object_object_add(res,code,cc2);
     1667    }
     1668  }
     1669
     1670  void addParameter(maps* conf,const char* oName,const char* fName,const char* in,json_object* res){
     1671    maps* tmpMaps1=getMaps(conf,oName);
     1672    json_object *res8=json_object_new_object();
     1673    if(tmpMaps1!=NULL){
     1674      map* tmpMap=getMap(tmpMaps1->content,"title");
     1675      if(tmpMap!=NULL)
     1676        json_object_object_add(res8,"x-internal-summary",json_object_new_string(tmpMap->value));
     1677      tmpMap=getMap(tmpMaps1->content,"abstract");
     1678      if(tmpMap!=NULL)
     1679        json_object_object_add(res8,"description",json_object_new_string(tmpMap->value));
     1680      tmpMap=getMap(tmpMaps1->content,"example");
     1681      if(tmpMap!=NULL)
     1682        json_object_object_add(res8,"example",json_object_new_string(tmpMap->value));
     1683      tmpMap=getMap(tmpMaps1->content,"required");
     1684      if(tmpMap!=NULL){
     1685        if(strcmp(tmpMap->value,"true")==0)
     1686          json_object_object_add(res8,"required",json_object_new_boolean(TRUE));
     1687        else
     1688          json_object_object_add(res8,"required",json_object_new_boolean(FALSE));
     1689      }
     1690      else
     1691        json_object_object_add(res8,"required",json_object_new_boolean(FALSE));
     1692      json_object_object_add(res8,"in",json_object_new_string(in));
     1693      json_object_object_add(res8,"name",json_object_new_string(fName));
     1694      json_object *res6=json_object_new_object();
     1695      tmpMap=getMap(tmpMaps1->content,"type");
     1696      if(tmpMap!=NULL)
     1697        json_object_object_add(res6,"type",json_object_new_string(tmpMap->value));
     1698      else
     1699        json_object_object_add(res6,"type",json_object_new_string("string"));
     1700       
     1701      json_object_object_add(res8,"schema",res6);
     1702       
     1703    }   
     1704    json_object_object_add(res,fName,res8);   
     1705  }
     1706 
    13861707  /**
    13871708   * Produce the JSON object for api parameter
     
    13971718    char *tmps12 = strtok_r (tmpMap2->value, ",", &saveptr12);
    13981719    while(tmps12!=NULL){
    1399       char* tmpId=(char*) malloc((strlen(tmps12)+3)*sizeof(char));
    1400       sprintf(tmpId,"{%s}",tmps12);
    1401       tmpMaps1=getMaps(conf,tmpId);
    1402       json_object *res8=json_object_new_object();
    1403       if(tmpMaps1!=NULL){
    1404         map* tmpMap=getMap(tmpMaps1->content,"title");
    1405         if(tmpMap!=NULL)
    1406           json_object_object_add(res8,"x-internal-summary",json_object_new_string(tmpMap->value));
    1407         tmpMap=getMap(tmpMaps1->content,"abstract");
    1408         if(tmpMap!=NULL)
    1409           json_object_object_add(res8,"description",json_object_new_string(tmpMap->value));
    1410         tmpMap=getMap(tmpMaps1->content,"example");
    1411         if(tmpMap!=NULL)
    1412           json_object_object_add(res8,"example",json_object_new_string(tmpMap->value));
    1413         tmpMap=getMap(tmpMaps1->content,"required");
    1414         if(tmpMap!=NULL){
    1415           if(strcmp(tmpMap->value,"true")==0)
    1416             json_object_object_add(res8,"required",json_object_new_boolean(TRUE));
    1417           else
    1418             json_object_object_add(res8,"required",json_object_new_boolean(FALSE));
    1419         }
    1420         else
    1421           json_object_object_add(res8,"required",json_object_new_boolean(FALSE));
    1422         json_object_object_add(res8,"in",json_object_new_string("path"));
    1423         json_object_object_add(res8,"name",json_object_new_string(tmps12));
    1424         json_object *res6=json_object_new_object();
    1425         json_object *res7=json_object_new_object();
    1426         tmpMap=getMap(tmpMaps1->content,"type");
    1427         if(tmpMap!=NULL)
    1428           json_object_object_add(res6,"type",json_object_new_string(tmpMap->value));
    1429         else
    1430           json_object_object_add(res6,"type",json_object_new_string("string"));
    1431        
    1432         json_object_object_add(res8,"schema",res6);
    1433        
    1434       }
    1435        
    1436       json_object_object_add(res9,tmps12,res8);
     1720      char* pacId=(char*) malloc((strlen(tmps12)+3)*sizeof(char));
     1721      sprintf(pacId,"{%s}",tmps12);
     1722      addParameter(conf,pacId,tmps12,"path",res9);
     1723      free(pacId);
    14371724      tmps12 = strtok_r (NULL, ",", &saveptr12);
    14381725    }   
    14391726    tmpMap2=getMapFromMaps(conf,"openapi","header_parameters");
    1440     char *saveptr13;
    1441     char *tmps13 = strtok_r (tmpMap2->value, ",", &saveptr13);
    1442     while(tmps13!=NULL){
    1443       char* tmpId=zStrdup(tmps13);
    1444       maps *tmpMaps2=getMaps(conf,tmpId);
    1445       json_object *res8=json_object_new_object();
    1446       if(tmpMaps2!=NULL){
    1447         map* tmpMap=getMap(tmpMaps2->content,"title");
    1448         if(tmpMap!=NULL)
    1449           json_object_object_add(res8,"x-internal-summary",json_object_new_string(tmpMap->value));
    1450         tmpMap=getMap(tmpMaps2->content,"abstract");
    1451         if(tmpMap!=NULL)
    1452           json_object_object_add(res8,"description",json_object_new_string(tmpMap->value));
    1453         tmpMap=getMap(tmpMaps2->content,"example");
    1454         if(tmpMap!=NULL)
    1455           json_object_object_add(res8,"example",json_object_new_string(tmpMap->value));
    1456         tmpMap=getMap(tmpMaps2->content,"required");
    1457         if(tmpMap!=NULL){
    1458           if(strcmp(tmpMap->value,"true")==0)
    1459             json_object_object_add(res8,"required",json_object_new_boolean(TRUE));
    1460           else
    1461             json_object_object_add(res8,"required",json_object_new_boolean(FALSE));
    1462         }
    1463         else
    1464           json_object_object_add(res8,"required",json_object_new_boolean(FALSE));
    1465         json_object_object_add(res8,"in",json_object_new_string("header"));
    1466         tmpMap=getMap(tmpMaps2->content,"name");
    1467         if(tmpMap!=NULL)
    1468           json_object_object_add(res8,"name",json_object_new_string(tmpMap->value));
    1469         json_object *res6=json_object_new_object();
    1470         json_object *res7=json_object_new_object();
    1471         tmpMap=getMap(tmpMaps2->content,"type");
    1472         if(tmpMap!=NULL)
    1473           json_object_object_add(res6,"type",json_object_new_string(tmpMap->value));
    1474         else
    1475           json_object_object_add(res6,"type",json_object_new_string("string"));
    1476 
    1477         {
    1478           tmpMap=getMap(tmpMaps2->content,"enum");
    1479           if(tmpMap!=NULL){
    1480             char *saveptr11;
    1481             char *tmps11 = strtok_r (tmpMap->value, ",", &saveptr11);
    1482             json_object *res71=json_object_new_array();
    1483             while(tmps11!=NULL){               
    1484               json_object_array_add(res71,json_object_new_string(tmps11));
    1485               tmps11 = strtok_r (NULL, ",", &saveptr11);
    1486             }
    1487             json_object_object_add(res6,"enum",res71);                           
    1488           }
    1489         }
    1490        
    1491         json_object_object_add(res8,"schema",res6);
    1492        
    1493       }
    1494        
    1495       json_object_object_add(res9,tmpId,res8);
    1496       tmps13 = strtok_r (NULL, ",", &saveptr13);
    1497     }
    1498     json_object_object_add(res,"parameters",res9);   
     1727    if(tmpMap2!=NULL){
     1728      char *saveptr13;
     1729      char *tmps13 = strtok_r (tmpMap2->value, ",", &saveptr13);
     1730      while(tmps13!=NULL){
     1731        char* pacId=zStrdup(tmps13);
     1732        addParameter(conf,pacId,pacId,"header",res9);
     1733        free(pacId);
     1734        tmps13 = strtok_r (NULL, ",", &saveptr13);
     1735      }
     1736    }
     1737    json_object_object_add(res,"parameters",res9);
     1738    maps* pmResponses=getMaps(conf,"responses");
     1739    if(pmResponses!=NULL){
     1740      json_object *cc=json_object_new_object();
     1741      map* pmLen=getMap(pmResponses->content,"length");
     1742      int iLen=atoi(pmLen->value);
     1743      map* pmUseContent=getMapFromMaps(conf,"openapi","use_content");
     1744      for(int i=0;i<iLen;i++){
     1745        map* cMap=getMapArray(pmResponses->content,"code",i);
     1746        map* vMap=getMapArray(pmResponses->content,"schema",i);
     1747        map* tMap=getMapArray(pmResponses->content,"type",i);
     1748        map* tMap0=getMapArray(pmResponses->content,"title",i);
     1749        if(vMap!=NULL)
     1750          addResponse(pmUseContent,cc,vMap,tMap,cMap->value,(tMap0==NULL)?"successful operation":tMap0->value);
     1751      }
     1752      json_object_object_add(res,"responses",cc);
     1753    }
    14991754  }
    15001755
     
    15041759    json_object_object_add(res,"components",res1);
    15051760  }
    1506 
     1761 
    15071762  /**
    15081763   * Produce the JSON object for /api
     
    15121767   */
    15131768  void produceApi(maps* conf,json_object* res){
     1769    // TODO: add 401 Gone for dismiss request
    15141770    json_object *res9=json_object_new_object();
    15151771    json_object *res10=json_object_new_object();
    15161772    maps* tmpMaps1=getMaps(conf,"{id}");
    1517 
    15181773    produceApiComponents(conf,res);
    15191774    json_object *res4=json_object_new_object();
     
    15621817            json_object *responses=json_object_new_object();
    15631818            json_object *cc3=json_object_new_object();
     1819            map* pmUseContent=getMapFromMaps(conf,"openapi","use_content");
    15641820            vMap=getMapArray(tmpMaps->content,"schema",i);
    15651821            if(vMap!=NULL){
    1566               json_object *cc=json_object_new_object();
    1567               json_object_object_add(cc,"$ref",json_object_new_string(vMap->value));
    1568               json_object *cc0=json_object_new_object();
    1569               json_object_object_add(cc0,"schema",cc);
    1570               json_object *cc1=json_object_new_object();
    1571               map* tmpMap3=getMapFromMaps(conf,tmps,"type");
    1572               if(tmpMap3!=NULL)
    1573                 json_object_object_add(cc1,tmpMap3->value,cc0);
    1574               else
    1575                 json_object_object_add(cc1,"application/json",cc0);
    1576               json_object *cc2=json_object_new_object();
    1577               json_object_object_add(cc2,"content",cc1);
    1578               json_object_object_add(cc2,"description",json_object_new_string("successful operation"));
    1579               if(i==1)
    1580                 json_object_object_add(cc3,"201",cc2);
    1581               else
    1582                 json_object_object_add(cc3,"200",cc2);
     1822              map* tMap=getMapArray(tmpMaps->content,"type",i);
     1823              addResponse(pmUseContent,cc3,vMap,tMap,"200","successful operation");
     1824              vMap=getMapArray(tmpMaps->content,"eschema",i);
     1825              if(vMap!=NULL && cMap!=NULL && strncasecmp(cMap->value,"post",4)==0)
     1826                addResponse(pmUseContent,cc3,vMap,tMap,"201","successful operation");
    15831827            }else{
    1584               json_object *cc1=json_object_new_object();
    1585               map* tmpMap3=getMapFromMaps(conf,tmps,"type");
    1586               if(tmpMap3!=NULL)
    1587                 json_object_object_add(cc1,tmpMap3->value,json_object_new_object());
    1588               else
    1589                 json_object_object_add(cc1,"application/json",json_object_new_object());
    1590               json_object *cc2=json_object_new_object();
    1591               json_object_object_add(cc2,"content",cc1);
    1592               json_object_object_add(cc2,"description",json_object_new_string("successful operation"));
    1593               if(i==1)
    1594                 json_object_object_add(cc3,"201",cc2);
    1595               else
    1596                 json_object_object_add(cc3,"200",cc2);
     1828              map* tMap=getMapFromMaps(conf,tmps,"type");
     1829              map* pMap=createMap("ok","true");
     1830              addResponse(pMap,cc3,vMap,tMap,"200","successful operation");
     1831              if(cMap!=NULL && strncasecmp(cMap->value,"post",4)==0)
     1832                addResponse(pmUseContent,cc3,vMap,tMap,"201","successful operation");
    15971833            }
    1598             if(strstr(tmps,"{id}")!=NULL){
    1599               vMap=getMapFromMaps(conf,"exception","schema");
    1600               json_object *cc=json_object_new_object();
    1601               json_object_object_add(cc,"$ref",json_object_new_string(vMap->value));
    1602               json_object *cc01=json_object_new_array();
    1603               json_object_array_add(cc01,cc);
    1604 
    1605               json_object *cc0=json_object_new_object();
    1606               json_object_object_add(cc0,"schema",cc);
    1607               json_object *cc1=json_object_new_object();
    1608               map* tmpMap3=getMapFromMaps(conf,"exception","type");
    1609               if(tmpMap3!=NULL)
    1610                 json_object_object_add(cc1,tmpMap3->value,cc0);
    1611               else
    1612                 json_object_object_add(cc1,"application/json",cc0);
    1613 
    1614               json_object *cc2=json_object_new_object();
    1615               json_object_object_add(cc2,"content",cc1);
    1616               if(strstr(tmps,"{jobID}")==NULL)
    1617                 json_object_object_add(cc2,"description",json_object_new_string("The process with id {id} does not exist."));
    1618               else
    1619                 json_object_object_add(cc2,"description",json_object_new_string("The process with id {id} or job with id {jobID} does not exist."));
    1620               json_object_object_add(cc3,"404",cc2);
    1621               json_object_object_add(cc3,"default",cc2);
     1834            vMap=getMapArray(tmpMaps->content,"ecode",i);
     1835            if(vMap!=NULL){
     1836              char *saveptr0;
     1837              char *tmps1 = strtok_r (vMap->value, ",", &saveptr0);
     1838              while(tmps1!=NULL){
     1839                char* tmpStr=(char*)malloc((strlen(tmps1)+24)*sizeof(char));
     1840                sprintf(tmpStr,"#/components/responses/%s",tmps1);
     1841                vMap=createMap("ok",tmpStr);
     1842                map* pMap=createMap("ok","false");
     1843                //TODO: fix successful operation with correct value
     1844                addResponse(pMap,cc3,vMap,NULL,tmps1,"successful operation");
     1845                tmps1 = strtok_r (NULL, ",", &saveptr0);
     1846              }
     1847            }else{
     1848              if(strstr(tmps,"{id}")!=NULL){
     1849                vMap=getMapFromMaps(conf,"exception","schema");
     1850                map* tMap=getMapFromMaps(conf,"exception","type");
     1851                if(vMap!=NULL)
     1852                  addResponse(pmUseContent,cc3,vMap,tMap,"404",
     1853                              (strstr(tmps,"{jobID}")==NULL)?"The process with id {id} does not exist.":"The process with id {id} or job with id {jobID} does not exist.");
     1854              }
    16221855            }
    16231856            json_object_object_add(methodc,"responses",cc3);
     
    16401873              json_object_object_add(methodc,"parameters",cc2);
    16411874            }
    1642             if(i==1){
     1875            if(i==1 && cMap!=NULL && strncasecmp(cMap->value,"post",4)==0){
    16431876              maps* tmpMaps1=getMaps(conf,"requestBody");
    16441877              if(tmpMaps1!=NULL){
     
    16631896                  json_object_object_add(methodc,"requestBody",cc2);
    16641897
     1898                }               
     1899              }
     1900              // TODO: callbacks
     1901              tmpMaps1=getMaps(conf,"callbacks");
     1902              if(tmpMaps1!=NULL){
     1903                map* pmTmp2=getMap(tmpMaps1->content,"length");
     1904                int iLen=atoi(pmTmp2->value);
     1905                json_object *pajRes=json_object_new_object();
     1906                for(int i=0;i<iLen;i++){
     1907                  map* pmState=getMapArray(tmpMaps1->content,"state",i);
     1908                  map* pmUri=getMapArray(tmpMaps1->content,"uri",i);
     1909                  map* pmSchema=getMapArray(tmpMaps1->content,"schema",i);
     1910                  map* pmType=getMapArray(tmpMaps1->content,"type",i);
     1911                  map* pmTitle=getMapArray(tmpMaps1->content,"title",i);
     1912                  json_object *pajSchema=json_object_new_object();
     1913                  if(pmSchema!=NULL)
     1914                    json_object_object_add(pajSchema,"$ref",json_object_new_string(pmSchema->value));
     1915                  json_object *pajType=json_object_new_object();
     1916                  json_object_object_add(pajType,"schema",pajSchema);
     1917                  json_object *pajContent=json_object_new_object();
     1918                  if(pmType!=NULL)
     1919                    json_object_object_add(pajContent,pmType->value,pajType);
     1920                  else           
     1921                    json_object_object_add(pajContent,"application/json",pajType);
     1922                  json_object *pajRBody=json_object_new_object();
     1923                  json_object_object_add(pajRBody,"content",pajContent);
     1924                 
     1925                  json_object *pajDescription=json_object_new_object();
     1926                  if(pmTitle!=NULL)
     1927                    json_object_object_add(pajDescription,"description",json_object_new_string(pmTitle->value));
     1928                  json_object *pajResponse=json_object_new_object();
     1929                  json_object_object_add(pajResponse,"200",pajDescription);
     1930
     1931                  json_object *pajPost=json_object_new_object();
     1932                  json_object_object_add(pajPost,"requestBody",pajRBody);
     1933                  json_object_object_add(pajPost,"responses",pajResponse);
     1934
     1935                  json_object *pajMethod=json_object_new_object();
     1936                  json_object_object_add(pajMethod,"post",pajPost);
     1937
     1938                 
     1939                  char* pacUri=(char*) malloc((strlen(pmUri->value)+29)*sizeof(char));
     1940                  sprintf(pacUri,"{$request.body#/subscriber/%s}",pmUri->value);
     1941
     1942                  json_object *pajFinal=json_object_new_object();
     1943                  json_object_object_add(pajFinal,pacUri,pajMethod);
     1944
     1945                  json_object_object_add(pajRes,pmState->value,pajFinal);
     1946
    16651947                }
     1948                json_object_object_add(methodc,"callbacks",pajRes);
    16661949              }
    16671950            }
  • trunk/zoo-project/zoo-kernel/service_json.h

    r949 r962  
    22 * Author : Gérald FENOY
    33 *
    4  *  Copyright 2014 GeoLabs SARL. All rights reserved.
     4 *  Copyright 2014-2020 GeoLabs SARL. All rights reserved.
    55 *
    66 * Permission is hereby granted, free of charge, to any person obtaining a copy
     
    5050  void printGetCapabilitiesForProcessJ(registry*, maps*,void*,void*,service*);
    5151  void printExceptionReportResponseJ(maps*,map*);
    52   void parseJRequest(maps*,service* s,json_object*,maps**,maps**);
     52  void parseJRequest(maps*,service* s,json_object*,map*,maps**,maps**);
    5353  json_object*  printJResult(maps*,service*,maps*,int);
    5454  json_object* printJobList(maps*);
    5555  int createStatusFile(maps*,int);
     56  json_object* createStatus(maps*,int);
     57  char* json_getStatusFilePath(maps*);
     58  json_object* parseJson(maps*,char*);
     59  json_object* json_readFile(maps*,char*);
     60  char* getResultPath(maps*,char*);
    5661  int json_getStatusFile(maps*);
    5762  void produceApi(maps*,json_object*);
  • trunk/zoo-project/zoo-kernel/sqlapi.c

    r955 r962  
    3333#include <fcgi_stdio.h>
    3434#include "sqlapi.h"
     35#include "service_callback.h"
    3536
    3637/**
     
    375376  map *msg=getMapFromMaps(conf,"lenv","message");
    376377  map *schema=getMapFromMaps(conf,"database","schema");
    377   char *sqlQuery=(char*)malloc((strlen(schema->value)+strlen(msg->value)+strlen(p->value)+strlen(sid->value)+64+1)*sizeof(char));
     378  char *sqlQuery=(char*)malloc((strlen(schema->value)+strlen(msg->value)+strlen(p->value)+strlen(sid->value)+62+1)*sizeof(char));
    378379  sprintf(sqlQuery,"UPDATE %s.services set status=$$%s$$,message=$$%s$$ where uuid=$$%s$$;",schema->value,p->value,msg->value,sid->value);
    379380  if( zoo_DS == NULL || zoo_DS[zoo_ds_nb-1]==NULL ){
     381    if(getMapFromMaps(conf,"lenv","file.log")==NULL){
     382      free(sqlQuery);
     383      return 1;
     384    }
    380385    init_sql(conf);
    381386    zoo_ds_nb++;
     
    384389  cleanUpResultSet(conf,zoo_ds_nb-1);
    385390  free(sqlQuery);
     391  invokeBasicCallback(conf,SERVICE_STARTED);
    386392  return 0;
    387393}
     
    398404  int created=-1;
    399405  map *schema=getMapFromMaps(conf,"database","schema");
    400   char *sqlQuery=(char*)malloc((strlen(schema->value)+strlen(pid)+58+1)*sizeof(char));
    401   sprintf(sqlQuery,"select status||'|'||message from %s.services where uuid=$$%s$$;",schema->value,pid);
     406  char *sqlQuery=(char*)malloc((strlen(schema->value)+strlen(pid)+104+1)*sizeof(char)); 
     407  sprintf(sqlQuery,"select CASE WHEN message is null THEN '-1' ELSE status||'|'||message END from %s.services where uuid=$$%s$$;",schema->value,pid);
    402408  if( zoo_ds_nb==
    403409#ifdef META_DB
  • trunk/zoo-project/zoo-kernel/zoo_loader.c

    r949 r962  
    105105       int len=0;
    106106       while((r=fread(buffer,sizeof(char),1,cgiIn))>0){
    107          fprintf(stderr,"%s",buffer);
    108107         buffer[1]=0;
    109108         if(res==NULL){
  • trunk/zoo-project/zoo-kernel/zoo_service_loader.c

    r955 r962  
    22 * Author : Gérald FENOY
    33 *
    4  *  Copyright 2008-2013 GeoLabs SARL. All rights reserved.
     4 *  Copyright 2008-2020 GeoLabs SARL. All rights reserved.
    55 *
    66 * Permission is hereby granted, free of charge, to any person obtaining a copy
     
    6363#include <string.h>
    6464
    65 #include "service.h"
    66 
    6765#include "service_internal.h"
    6866#include "server_internal.h"
    6967#include "response_print.h"
    7068#include "request_parser.h"
     69#include "service.h"
     70
    7171#ifdef USE_JSON
    7272#include "caching.h"
     
    106106#endif
    107107
    108 #ifdef USE_CALLBACK
     108#if defined(USE_CALLBACK) || defined(USE_JSON)
    109109#include "service_callback.h"
    110110#endif
     
    417417             _("Unable to parse the ZCFG file: %s."),
    418418             zcfg);
     419 
    419420  map* errormap = createMap("text", tmp01);
    420   addToMap(errormap,"code", code);
     421  map* tmpMap=getMapFromMaps(m,"lenv","executionType");
     422  char* errorCode=(char*)code;
     423  if(tmpMap!=NULL && strncasecmp(tmpMap->value,"json",4)==0)
     424    errorCode="NoSuchProcess";
     425
     426  addToMap(errormap,"code", errorCode);
    421427  addToMap(errormap,"locator", locator);
    422428  funcError(m,errormap);
     
    685691  fflush (stdout);
    686692  zDup2 (saved_stdout, fileno (stdout));
     693  zClose(saved_stdout);
    687694  free (orig);
    688695  return 0;
     
    18701877#endif
    18711878  }
    1872  
     1879
     1880  int eres = SERVICE_STARTED;
     1881  int cpid = zGetpid ();
     1882  maps* bmap=NULL;
     1883  char *fbkp, *fbkpid, *fbkpres, *fbkp1, *flog;
     1884  FILE *f0, *f1;
     1885  HINTERNET hInternet;
     1886  service *s1;
     1887  maps *request_output_real_format = NULL;
     1888  maps *request_input_real_format = NULL;
     1889
    18731890  setMapInMaps(m,"lenv","executionType","xml");
    1874   if((strlen(cgiQueryString)>0 && cgiQueryString[0]=='/') && strstr(cgiAccept,"json")!=NULL){
    1875   //
    1876   // OGC API - Processing starts here
    1877   //
     1891  if((strlen(cgiQueryString)>0 && cgiQueryString[0]=='/') /*&& strstr(cgiAccept,"json")!=NULL*/){
     1892    //
     1893    // OGC API - Processing starts here
     1894    //
    18781895#ifndef USE_JSON
    18791896    errorException (m, _("OGC API - Processing is not supported by this ZOO-Kernel."), "InternalError", NULL);
     
    19041921    addMapsToMaps(&m,m1);
    19051922    setMapInMaps(m,"lenv","executionType","json");
    1906 
     1923    map* pmTmp0=getMapFromMaps(m,"openapi","full_html_support");
     1924    dumpMap(pmTmp0);
     1925    if(strstr(cgiQueryString,".html")==NULL && strstr(cgiAccept,"text/html")!=NULL && pmTmp0!=NULL && strncasecmp(pmTmp0->value,"true",4)==0){
     1926      map* pmTmpUrl=getMapFromMaps(m,"openapi","rootUrl");
     1927      char* pacTmpUrl=NULL;
     1928      if(strcmp(cgiQueryString,"/")!=0){
     1929         pacTmpUrl=(char*)malloc((strlen(cgiQueryString)+strlen(pmTmpUrl->value)+6)*sizeof(char));
     1930         sprintf(pacTmpUrl,"%s%s.html",pmTmpUrl->value,cgiQueryString);
     1931      }
     1932      else{
     1933        pacTmpUrl=(char*)malloc((strlen(pmTmpUrl->value)+6)*sizeof(char));
     1934        sprintf(pacTmpUrl,"%s/index.html",pmTmpUrl->value);
     1935      }
     1936      setMapInMaps(m,"headers","Location",pacTmpUrl);
     1937      printHeaders(m);
     1938      printf("Status: 302 Moved permanently \r\n\r\n");
     1939      fflush(stdout);
     1940      free(pacTmpUrl);
     1941      return 1;
     1942    }
    19071943    json_object *res=json_object_new_object();
    19081944    setMapInMaps(m,"headers","Content-Type","application/json;charset=UTF-8");
     
    19171953      for(int kk=0;kk<4;kk++){
    19181954        maps* tmpMaps=getMaps(m,urls[kk]);
    1919         json_object *res2;
    19201955        if(tmpMaps!=NULL){
     1956          json_object *res2;
    19211957          res2=mapToJson(tmpMaps->content);
    19221958          char* tmpStr=(char*) malloc((strlen(tmpUrl->value)+strlen(urls[kk])+2)*sizeof(char));
    19231959          sprintf(tmpStr,"%s%s",tmpUrl->value,urls[kk]);
    19241960          json_object_object_add(res2,"href",json_object_new_string(tmpStr));
     1961          free(tmpStr);
    19251962          json_object_array_add(res1,res2);
     1963
     1964          map* pmTmp=getMap(tmpMaps->content,"title");
     1965          char *pacTitle=NULL;
     1966          if(pmTmp!=NULL)
     1967            pacTitle=zStrdup(pmTmp->value);
     1968          char* pacTmp=(char*) malloc((strlen(urls[kk])+6)*sizeof(char));
     1969          sprintf(pacTmp,"%s.html",urls[kk]);
     1970          tmpMaps=getMaps(m,pacTmp);
     1971          if(tmpMaps==NULL && strncasecmp(pacTmp,"/.html",6)==0)
     1972            tmpMaps=getMaps(m,"/index.html");
     1973          if(tmpMaps!=NULL){
     1974            json_object *res3;
     1975            res3=mapToJson(tmpMaps->content);
     1976            if(getMap(tmpMaps->content,"title")==NULL && pacTitle!=NULL){
     1977              json_object_object_add(res3,"title",json_object_new_string(pacTitle));
     1978            }
     1979            char* tmpStr=NULL;
     1980            if(strncasecmp(pacTmp,"/.html",6)==0){
     1981              tmpStr=(char*) malloc((strlen(tmpUrl->value)+12)*sizeof(char));
     1982              sprintf(tmpStr,"%s/index.html",tmpUrl->value);
     1983            }else{
     1984              tmpStr=(char*) malloc((strlen(tmpUrl->value)+strlen(urls[kk])+6)*sizeof(char));
     1985              sprintf(tmpStr,"%s%s.html",tmpUrl->value,urls[kk]);
     1986            }
     1987            json_object_object_add(res3,"href",json_object_new_string(tmpStr));
     1988            free(tmpStr);
     1989            json_object_array_add(res1,res3);
     1990          }
     1991          free(pacTmp);
     1992          if(pacTitle!=NULL)
     1993            free(pacTitle);       
    19261994        }
    19271995      }
     1996      map* pmTmp=getMapFromMaps(m,"identification","title");
     1997      if(pmTmp!=NULL)
     1998        json_object_object_add(res,"title",json_object_new_string(pmTmp->value));
     1999      pmTmp=getMapFromMaps(m,"identification","abstract");
     2000      if(pmTmp!=NULL)
     2001        json_object_object_add(res,"description",json_object_new_string(pmTmp->value));
    19282002      json_object_object_add(res,"links",res1);
    19292003    }else if(strcmp(cgiQueryString,"/conformance")==0){
    19302004      /* - /conformance url */
    1931       map* rootUrl=getMapFromMaps(m,"conformTo","rootUrl");
     2005      map* rootUrl=getMapFromMaps(m,"conformsTo","rootUrl");
    19322006      json_object *res1=json_object_new_array();
    1933       map* length=getMapFromMaps(m,"conformTo","length");
    1934       maps* tmpMaps=getMaps(m,"conformTo");
     2007      map* length=getMapFromMaps(m,"conformsTo","length");
     2008      maps* tmpMaps=getMaps(m,"conformsTo");
    19352009      for(int kk=0;kk<atoi(length->value);kk++){
    19362010        map* tmpMap1=getMapArray(tmpMaps->content,"link",kk);
     
    19422016        }
    19432017      }
    1944       json_object_object_add(res,"conformTo",res1);
    1945     }else if(strcmp(cgiQueryString,"/api")==0){
    1946       /* - /api url */
    1947       produceApi(m,res);
     2018      json_object_object_add(res,"conformsTo",res1);
     2019    }else if(strncasecmp(cgiQueryString,"/api",4)==0){
     2020      if(strstr(cgiQueryString,".html")==NULL)
     2021        produceApi(m,res);
     2022      else{     
     2023        char* pacTmp=(char*)malloc(9*sizeof(char));
     2024        sprintf(pacTmp,"%s",cgiQueryString+1);
     2025        map* pmTmp=getMapFromMaps(m,pacTmp,"href");
     2026        free(pacTmp);
     2027        if(pmTmp!=NULL)
     2028          setMapInMaps(m,"headers","Location",pmTmp->value);
     2029      }
    19482030    }else if(strcmp(cgiQueryString,"/processes")==0 || strcmp(cgiQueryString,"/processes/")==0){
    19492031      /* - /processes */
     2032      setMapInMaps(m,"lenv","requestType","desc");
    19502033      json_object *res3=json_object_new_array();
    19512034      int saved_stdout = zDup (fileno (stdout));
    19522035      zDup2 (fileno (stderr), fileno (stdout));
    1953 
    1954       if (int res =               
     2036      if (int res0 =             
    19552037          recursReaddirF (m, NULL, res3, NULL, ntmp, NULL, saved_stdout, 0,
    19562038                          printGetCapabilitiesForProcessJ) < 0)
     
    19592041      zDup2 (saved_stdout, fileno (stdout));
    19602042      zClose(saved_stdout);
    1961      
    1962       json_object_object_add(res,"processes",res3);
     2043      res=res3;
     2044      //json_object_object_add(res,"processes",res3);
    19632045    }else{
    19642046      service* s1=NULL;
     
    19842066            orig[strlen(orig)-1]=0;
    19852067          json_object* res1=json_object_new_object();
     2068          setMapInMaps(m,"lenv","requestType","GetCapabilities");
    19862069          int t=fetchServicesForDescription(NULL, m, orig,
    19872070                                            printGetCapabilitiesForProcessJ,
     
    19912074          if(t==1){
    19922075            /*map* error=createMap("code","BadRequest");
    1993             addToMap(error,"message",_("Failed to acces the requested service"));
    1994             printExceptionReportResponseJ(m,error);*/
     2076              addToMap(error,"message",_("Failed to acces the requested service"));
     2077              printExceptionReportResponseJ(m,error);*/
    19952078            return 1;
    19962079          }
     
    20032086          int cnt=0;
    20042087          for(int j=11;j<len1;j++){
    2005             fprintf(stderr,"%s %c\n",cIdentifier,cgiQueryString[j]);
    20062088            cIdentifier[cnt]=cgiQueryString[j];
    20072089            cIdentifier[cnt+1]=0;
     
    20092091          }
    20102092          char tmps1[1024];
    2011 
    20122093          map* import = getMapFromMaps (m, IMPORTSERVICE, cIdentifier);
    20132094          if (import != NULL && import->value != NULL) {
     
    20232104            if (strstr (cIdentifier, ".") != NULL)
    20242105              {
     2106                setMapInMaps (m, "lenv", "oIdentifier", cIdentifier);
    20252107                char *identifier = zStrdup (cIdentifier);
    20262108                parseIdentifier (m, ntmp, identifier, tmps1);
     
    20712153                map* error=createMap("code","InternalError");
    20722154                addToMap(error,"message",_("Unable to allocate memory"));
    2073                 //setMapInMaps(conf,"lenv","status_code","404 Bad Request");
     2155                setMapInMaps(m,"lenv","status_code","404 Bad Request");
    20742156                printExceptionReportResponseJ(m,error);
    20752157
     
    20912173              free(zooRegistry);
    20922174            }
     2175            fflush(stderr);
    20932176            fflush (stdout);
    20942177            zDup2 (saved_stdout, fileno (stdout));
     2178            zClose (saved_stdout);
    20952179            if (t < 0)
    20962180              {
    2097                 char *tmpMsg = (char *) malloc (2048 + strlen (r_inputs->value));
    2098                 sprintf (tmpMsg,
    2099                          _
    2100                          ("The value for <identifier> seems to be wrong (%s). Please specify one of the processes in the list returned by a GetCapabilities request."),
    2101                          r_inputs->value);
    2102                 map* error=createMap("code","InvalidParameterValue");
    2103                 addToMap(error,"message",tmpMsg);
    2104                 //setMapInMaps(conf,"lenv","status_code","404 Bad Request");
    2105                 printExceptionReportResponseJ(m,error);
    2106 
    2107                 //errorException (m, tmpMsg, "InvalidParameterValue", "identifier");
    2108                 free (tmpMsg);
    2109                 free (s1);
    2110                 freeMaps (&m);
    2111                 free (m);
    2112                 free (REQUEST);
    2113                 free (SERVICE_URL);
    2114                 return 0;
     2181                r_inputs = getMapFromMaps (m, "lenv", "oIdentifier");
     2182                if(r_inputs!=NULL){
     2183                  char *tmpMsg = (char *) malloc (2048 + strlen (r_inputs->value));
     2184                  sprintf (tmpMsg,
     2185                           _
     2186                           ("The value for <identifier> seems to be wrong (%s). Please specify one of the processes in the list returned by a GetCapabilities request."),
     2187                           r_inputs->value);
     2188                  map* error=createMap("code","NoSuchProcess");
     2189                  addToMap(error,"message",tmpMsg);
     2190                  //setMapInMaps(conf,"lenv","status_code","404 Bad Request");
     2191                  printExceptionReportResponseJ(m,error);
     2192
     2193                  //errorException (m, tmpMsg, "InvalidParameterValue", "identifier");
     2194                  free (tmpMsg);
     2195                  free (s1);
     2196                  freeMaps (&m);
     2197                  free (m);
     2198                  free (REQUEST);
     2199                  free (SERVICE_URL);
     2200                  return 0;
     2201                }
    21152202              }
    2116             zClose (saved_stdout);
    2117          
    21182203#ifdef META_DB
    21192204          }
    21202205#endif
    2121           if(strstr(cgiQueryString,"/jobs/")!=NULL && strlen(strstr(cgiQueryString,"/jobs/"))>6){
     2206          if(strstr(cgiQueryString,"/jobs/")!=NULL && strlen(strstr(cgiQueryString,"/jobs/"))>6) {
    21222207            /* - /jobs/{jobID} and /jobs/{jobID}/result urls */
    2123             if(strstr(cgiQueryString,"/result")!=NULL && strlen(strstr(cgiQueryString,"/result"))>=7){
    2124               fprintf(stderr,"For GetResult %s %d \n",__FILE__,__LINE__);
     2208            if(strstr(cgiQueryString,"/results")!=NULL){
     2209              // In case the service has run, then forward request to target result file
     2210              char* jobId=zStrdup(strstr(cgiQueryString,"/jobs/")+6);
     2211              jobId[strlen(jobId)-8]=0;
     2212              char *sid=getStatusId(m,jobId);
     2213              if(sid==NULL){
     2214                map* error=createMap("code","NoSuchJob");
     2215                addToMap(error,"message",_("The JobID from the request does not match any of the Jobs running on this server"));
     2216                printExceptionReportResponseJ(m,error);
     2217                return 1;
     2218              }else{
     2219                if(isRunning(m,jobId)>0){
     2220                  map* error=createMap("code","ResultNotReady");
     2221                  addToMap(error,"message",_("The job is still running."));
     2222                  printExceptionReportResponseJ(m,error);
     2223                  return 1;
     2224                }else{
     2225                  char *Url0=getResultPath(m,jobId);
     2226                  map *cIdentifier = getMapFromMaps (m, "lenv", "oIdentifier");
     2227                  zStatStruct f_status;
     2228                  int s=zStat(Url0, &f_status);
     2229                  if(s==0 && f_status.st_size>0){
     2230                    if(f_status.st_size>15){
     2231                      json_object* pjoTmp=json_readFile(m,Url0);
     2232                      json_object* pjoCode=NULL;
     2233                      json_object* pjoMessage=NULL;
     2234                      if(pjoTmp!=NULL &&
     2235                         json_object_object_get_ex(pjoTmp,"code",&pjoCode)!=FALSE &&
     2236                         json_object_object_get_ex(pjoTmp,"description",&pjoMessage)!=FALSE){
     2237                        map* error=createMap("code",json_object_get_string(pjoCode));
     2238                        addToMap(error,"message",json_object_get_string(pjoMessage));
     2239                        printExceptionReportResponseJ(m,error);
     2240                        return 1;                       
     2241                      }else{
     2242
     2243                        map* tmpPath = getMapFromMaps (m, "main", "tmpUrl");
     2244                        Url0=(char*) realloc(Url0,(strlen(tmpPath->value)+
     2245                                                   strlen(cIdentifier->value)+
     2246                                                   strlen(jobId)+8)*sizeof(char));
     2247                        sprintf(Url0,"%s/%s_%s.json",tmpPath->value,
     2248                                cIdentifier->value,jobId);
     2249                        setMapInMaps(m,"headers","Location",Url0);
     2250                      }
     2251                      free(Url0);
     2252                    }else{
     2253                      // Service Failed
     2254                      map* statusInfo=createMap("JobID",jobId);
     2255                      readFinalRes(m,jobId,statusInfo);
     2256                      {
     2257                        map* pmStatus=getMap(statusInfo,"status");
     2258                        if(pmStatus!=NULL)
     2259                          setMapInMaps(m,"lenv","status",pmStatus->value);
     2260                      }
     2261                      char* tmpStr=_getStatus(m,jobId);
     2262                      if(tmpStr!=NULL && strncmp(tmpStr,"-1",2)!=0){
     2263                        char *tmpStr1=zStrdup(tmpStr);
     2264                        char *tmpStr0=zStrdup(strstr(tmpStr,"|")+1);
     2265                        free(tmpStr);
     2266                        tmpStr1[strlen(tmpStr1)-strlen(tmpStr0)-1]='\0';
     2267                        addToMap(statusInfo,"PercentCompleted",tmpStr1);
     2268                        addToMap(statusInfo,"Message",tmpStr0);
     2269                        setMapInMaps(m,"lenv","PercentCompleted",tmpStr1);
     2270                        setMapInMaps(m,"lenv","Message",tmpStr0);
     2271                        free(tmpStr0);
     2272                        free(tmpStr1);
     2273                      }
     2274                      map* error=createMap("code","NoApplicableCode");
     2275                      addToMap(error,"message",_("The service failed to execute."));
     2276                      printExceptionReportResponseJ(m,error);
     2277                      return 1;
     2278                    }
     2279
     2280                  }else{
     2281                    map* error=createMap("code","NoSuchJob");
     2282                    addToMap(error,"message",_("The JobID seem to be running on this server but not for this process id"));
     2283                    printExceptionReportResponseJ(m,error);
     2284                    return 1;
     2285                  }
     2286                }
     2287              }
    21252288            }else{
    21262289              char* tmpUrl=strstr(cgiQueryString,"/jobs/");
    21272290              if(tmpUrl!=NULL && strlen(tmpUrl)>6){
    2128                 char* jobId=zStrdup(strstr(cgiQueryString,"/jobs/")+6);
    2129                 setMapInMaps(m,"lenv","gs_usid",jobId);
    2130                 json_getStatusFile(m);
    2131                 free(jobId);
    2132                 return 1;             
     2291                if(strncasecmp(cgiRequestMethod,"DELETE",6)==0){
     2292                  char* jobId=zStrdup(strstr(cgiQueryString,"/jobs/")+6);
     2293                  setMapInMaps(m,"lenv","gs_usid",jobId);
     2294                  setMapInMaps(m,"lenv","file.statusFile",json_getStatusFilePath(m));
     2295                  runDismiss(m,jobId);
     2296                  map* pmError=getMapFromMaps(m,"lenv","error");
     2297                  if(pmError!=NULL && strncasecmp(pmError->value,"true",4)==0){
     2298                    printExceptionReportResponseJ(m,getMapFromMaps(m,"lenv","code"));
     2299                    return 1;
     2300                  }
     2301                  else{
     2302                    setMapInMaps(m,"lenv","gs_location","false");
     2303                    res=createStatus(m,SERVICE_DISMISSED);
     2304                  }
     2305                }else{
     2306                  char* jobId=zStrdup(strstr(cgiQueryString,"/jobs/")+6);
     2307                  runGetStatus(m,jobId,"GetStatus");
     2308                  map* pmError=getMapFromMaps(m,"lenv","error");
     2309                  if(pmError!=NULL && strncasecmp(pmError->value,"true",4)==0){
     2310                    printExceptionReportResponseJ(m,getMapFromMaps(m,"lenv","code"));
     2311                    return 1;
     2312                  }else{
     2313                    map* pmStatus=getMapFromMaps(m,"lenv","status");
     2314                    setMapInMaps(m,"lenv","gs_location","false");
     2315                    setMapInMaps(m,"lenv","gs_usid",jobId);
     2316                    if(pmStatus!=NULL && strncasecmp(pmStatus->value,"Failed",6)==0)
     2317                      res=createStatus(m,SERVICE_FAILED);
     2318                    else
     2319                      if(pmStatus!=NULL  && strncasecmp(pmStatus->value,"Succeeded",9)==0)
     2320                        res=createStatus(m,SERVICE_SUCCEEDED);
     2321                      else
     2322                        if(pmStatus!=NULL  && strncasecmp(pmStatus->value,"Running",7)==0){
     2323                          map* tmpMap=getMapFromMaps(m,"lenv","Message");
     2324                          if(tmpMap!=NULL)
     2325                            setMapInMaps(m,"lenv","gs_message",tmpMap->value);
     2326                          res=createStatus(m,SERVICE_STARTED);
     2327                        }
     2328                        else
     2329                          res=createStatus(m,SERVICE_FAILED);
     2330                  }
     2331                  free(jobId);
     2332                }
    21332333              }
    21342334            }
    21352335          }else{
    21362336            /* - /jobs url */
    2137             fprintf(stderr,"For Execute or Job list %s %d \n",__FILE__,__LINE__);
    21382337            if(strcasecmp(cgiRequestMethod,"get")==0){
    21392338              /* - /jobs List (GET) */
     
    21412340            }else if(strcasecmp(cgiRequestMethod,"post")==0){
    21422341              /* - /jobs Execution (POST) */
    2143               int eres = SERVICE_STARTED;
    2144 
     2342              eres = SERVICE_STARTED;
    21452343              initAllEnvironment(m,request_inputs,ntmp,"jrequest");
    21462344              map* req=getMapFromMaps(m,"renv","jrequest");
     
    21562354              } while ((jerr = json_tokener_get_error(tok)) == json_tokener_continue);
    21572355              if (jerr != json_tokener_success) {
     2356                map* pamError=createMap("code","InvalidParameterValue");
     2357                const char* pcTmpErr=json_tokener_error_desc(jerr);
     2358                const char* pccErr=_("ZOO-Kernel cannot parse your POST data: %s");
     2359                char* pacMessage=(char*)malloc((strlen(pcTmpErr)+strlen(pccErr)+1)*sizeof(char));
     2360                sprintf(pacMessage,pccErr,pcTmpErr);
     2361                addToMap(pamError,"message",pacMessage);
     2362                printExceptionReportResponseJ(m,pamError);
    21582363                fprintf(stderr, "Error: %s\n", json_tokener_error_desc(jerr));
    21592364                return 1;
    21602365              }
    21612366              if (tok->char_offset < slen){
     2367                map* pamError=createMap("code","InvalidParameterValue");
     2368                const char* pcTmpErr="None";
     2369                const char* pccErr=_("ZOO-Kernel cannot parse your POST data: %s");
     2370                char* pacMessage=(char*)malloc((strlen(pcTmpErr)+strlen(pccErr)+1)*sizeof(char));
     2371                sprintf(pacMessage,pccErr,pcTmpErr);
     2372                addToMap(pamError,"message",pacMessage);
     2373                printExceptionReportResponseJ(m,pamError);
     2374                fprintf(stderr, "Error: %s\n", json_tokener_error_desc(jerr));
    21622375                return 1;
    21632376              }
    2164               fprintf(stderr,"%s %d \n",__FILE__,__LINE__);
    2165               // Success, use jobj here.
    2166               maps* inputs_real_format=NULL, *outputs_real_format= NULL;
    2167               parseJRequest(m,s1,jobj,&inputs_real_format,&outputs_real_format);
     2377              //maps* inputs_real_format=NULL, *outputs_real_format= NULL;
     2378              parseJRequest(m,s1,jobj,request_inputs,&request_input_real_format,&request_output_real_format);
    21682379              map* preference=getMapFromMaps(m,"renv","HTTP_PREFER");
    2169               if(preference!=NULL && strcasecmp(preference->value,"respond-async")==0){
    2170                 fprintf(stderr,"Asynchronous call!\n");
    2171                 char *fbkp, *fbkpid, *fbkpres, *fbkp1, *flog;
    2172                 FILE *f0, *f1;
     2380              map* mode=getMap(request_inputs,"mode");
     2381              if((preference!=NULL && strcasecmp(preference->value,"respond-async")==0) ||
     2382                 (mode!=NULL && strncasecmp(mode->value,"async",5)==0)) {
    21732383                int pid;
    21742384#ifdef DEBUG
     
    22042414                    eres = SERVICE_ACCEPTED;
    22052415                    createStatusFile(m,eres);
     2416                    //invokeBasicCallback(m,SERVICE_ACCEPTED);
    22062417                    printHeaders(m);
    22072418                    printf("Status: 201 Created \r\n\r\n");
     
    22152426                    // process answer to http client.
    22162427                    //
     2428                    map* oid = getMapFromMaps (m, "lenv", "oIdentifier");
    22172429                    map* usid = getMapFromMaps (m, "lenv", "uusid");
    22182430                    map* tmpm = getMapFromMaps (m, "lenv", "osid");
     
    22282440                               strlen (usid->value) + 7) * sizeof (char));                   
    22292441                    sprintf (fbkpres, "%s/%s.res", r_inputs->value, usid->value);
    2230                     maps* bmap = createMaps("status");
     2442                    bmap = createMaps("status");
    22312443                    bmap->content=createMap("usid",usid->value);
    22322444                    addToMap(bmap->content,"sid",tmpm->value);
     
    22482460                    fbkp =
    22492461                      (char *)
    2250                       malloc ((strlen (r_inputs->value) + strlen (r_inputs1->value) +
     2462                      malloc ((strlen (r_inputs->value) + strlen (oid->value) +
    22512463                               strlen (usid->value) + 7) * sizeof (char));
    22522464                    sprintf (fbkp, "%s/%s.sid", r_inputs->value, usid->value);
     
    22592471                    fbkp =
    22602472                      (char *)
    2261                       malloc ((strlen (r_inputs->value) + strlen (r_inputs1->value) +
     2473                      malloc ((strlen (r_inputs->value) + strlen (oid->value) +
    22622474                               strlen (usid->value) + 7) * sizeof (char));
    2263                     sprintf (fbkp, "%s/%s_%s.xml", r_inputs->value, r_inputs1->value,
     2475                    sprintf (fbkp, "%s/%s_%s.json", r_inputs->value, oid->value,
    22642476                             usid->value);
    22652477                    setMapInMaps (m, "lenv", "file.responseInit", fbkp);
    22662478                    flog =
    22672479                      (char *)
    2268                       malloc ((strlen (r_inputs->value) + strlen (r_inputs1->value) +
     2480                      malloc ((strlen (r_inputs->value) + strlen (oid->value) +
    22692481                               strlen (usid->value) + 13) * sizeof (char));
    22702482                    sprintf (flog, "%s/%s_%s_error.log", r_inputs->value,
    2271                              r_inputs1->value, usid->value);
     2483                             oid->value, usid->value);
    22722484                    setMapInMaps (m, "lenv", "file.log", flog);
    22732485#ifdef DEBUG
     
    22912503                    invokeCallback(m,NULL,NULL,0,0);
    22922504#endif
    2293                     fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
    2294                     fflush(stderr);
    2295                    
    2296                     createStatusFile(m,eres);
    2297                          
    2298                  
     2505                    invokeBasicCallback(m,SERVICE_STARTED);
     2506                    createStatusFile(m,SERVICE_STARTED);
    22992507                    fbkp1 =
    23002508                      (char *)
    2301                       malloc ((strlen (r_inputs->value) + strlen (r_inputs1->value) +
     2509                      malloc ((strlen (r_inputs->value) + strlen (oid->value) +
    23022510                               strlen (usid->value) + 15) * sizeof (char));
    23032511                    sprintf (fbkp1, "%s/%s_final_%s.json", r_inputs->value,
    2304                              r_inputs1->value, usid->value);
     2512                             oid->value, usid->value);
    23052513                    setMapInMaps (m, "lenv", "file.responseFinal", fbkp1);
    23062514
     
    23172525                    sprintf (flenv, "%s/%s_lenv.cfg", r_inputs->value, usid->value);
    23182526                    maps* lenvMaps=getMaps(m,"lenv");
    2319                     dumpMapsToFile(lenvMaps,flenv,0);
     2527                    dumpMapsToFile(lenvMaps,flenv,1);
    23202528                    free(flenv);
    23212529
    23222530                    map* testMap=getMapFromMaps(m,"main","memory");
    2323                     loadHttpRequests(m,inputs_real_format);
     2531                    loadHttpRequests(m,request_input_real_format);
     2532                    dumpMaps(request_input_real_format);
    23242533                    loadServiceAndRun (&m, s1, request_inputs,
    2325                                        &inputs_real_format,
    2326                                        &outputs_real_format, &eres);
     2534                                       &request_input_real_format,
     2535                                       &request_output_real_format, &eres);
     2536                    setMapInMaps(m,"lenv","force","true");
    23272537                    createStatusFile(m,eres);
    2328                     res=printJResult(m,s1,outputs_real_format,eres);
    2329                     char tmpUrl0[1024];
    2330                     const char* jsonStr=json_object_to_json_string_ext(res,JSON_C_TO_STRING_PLAIN);
    2331                     printf(jsonStr);
    2332                     printf("\n");
    2333                     return 1;
    2334 
     2538                    setMapInMaps(m,"lenv","force","false");
     2539                    setMapInMaps(m,"lenv","no-headers","true");
     2540                    fflush(stdout);
     2541                    rewind(stdout);
     2542                    res=printJResult(m,s1,request_output_real_format,eres);
     2543                    const char* jsonStr0=json_object_to_json_string_ext(res,JSON_C_TO_STRING_PLAIN);
     2544                    if(getMapFromMaps(m,"lenv","jsonStr")==NULL)
     2545                      setMapInMaps(m,"lenv","jsonStr",jsonStr0);
     2546                    invokeBasicCallback(m,eres);
    23352547                  }
    23362548              }else{
    2337                 loadHttpRequests(m,inputs_real_format);
    2338                 loadServiceAndRun (&m,s1,request_inputs,&inputs_real_format,&outputs_real_format,&eres);
    2339                 res=printJResult(m,s1,outputs_real_format,eres);
    2340              
    2341                 printHeaders(m);
    2342                 printf("Status: 201 Created \r\n\r\n");
    2343                 const char* jsonStr=json_object_to_json_string_ext(res,JSON_C_TO_STRING_PLAIN);
    2344                 printf(jsonStr);
    2345                 printf("\n");
    2346                 return 1;
     2549                loadHttpRequests(m,request_input_real_format);
     2550                loadServiceAndRun (&m,s1,request_inputs,
     2551                                   &request_input_real_format,
     2552                                   &request_output_real_format,&eres);
     2553                res=printJResult(m,s1,request_output_real_format,eres);
    23472554              }
    23482555
     
    23532560        }
    23542561    }
    2355     printHeaders(m);
    2356     printf("Status: 200 OK \r\n\r\n");
    2357     const char* jsonStr=json_object_to_json_string_ext(res,JSON_C_TO_STRING_PLAIN);
    2358     printf(jsonStr);
    2359     printf("\n");
    2360     return 1;
    2361 #endif
    2362   }
    2363 
    2364   //
    2365   // WPS 1.0.0 and 2.0.0 starts here
    2366   //
    2367   //Check for minimum inputs
    2368   map* version=getMap(request_inputs,"version");
    2369   if(version==NULL)
    2370     version=getMapFromMaps(m,"main","version");
    2371   setMapInMaps(m,"main","rversion",version->value);
    2372   int vid=getVersionId(version->value);
    2373   if(vid<0)
    2374     vid=0;
    2375   map* err=NULL;
    2376   const char **vvr=(const char**)requests[vid];
    2377   checkValidValue(request_inputs,&err,"request",vvr,1);
    2378   const char *vvs[]={
    2379     "WPS",
    2380     NULL
    2381   };
    2382   if(err!=NULL){
     2562    if(res!=NULL){
     2563      if(getMapFromMaps(m,"lenv","no-headers")==NULL){
     2564        printHeaders(m);
     2565        printf("Status: 200 OK \r\n\r\n");
     2566      }
     2567      const char* jsonStr=json_object_to_json_string_ext(res,JSON_C_TO_STRING_PLAIN);
     2568      printf(jsonStr);
     2569      printf("\n");
     2570      fflush(stdout);
     2571    }
     2572    //return 1;
     2573#endif
     2574  }else{
     2575
     2576    //
     2577    // WPS 1.0.0 and 2.0.0 starts here
     2578    //
     2579    //Check for minimum inputs
     2580    map* version=getMap(request_inputs,"version");
     2581    if(version==NULL)
     2582      version=getMapFromMaps(m,"main","version");
     2583    setMapInMaps(m,"main","rversion",version->value);
     2584    int vid=getVersionId(version->value);
     2585    if(vid<0)
     2586      vid=0;
     2587    map* err=NULL;
     2588    const char **vvr=(const char**)requests[vid];
     2589    checkValidValue(request_inputs,&err,"request",vvr,1);
     2590    const char *vvs[]={
     2591      "WPS",
     2592      NULL
     2593    };
     2594    if(err!=NULL){
     2595      checkValidValue(request_inputs,&err,"service",(const char**)vvs,1);
     2596      printExceptionReportResponse (m, err);
     2597      freeMap(&err);
     2598      free(err);
     2599      if (count (request_inputs) == 1)
     2600        {
     2601          freeMap (&request_inputs);
     2602          free (request_inputs);
     2603        }
     2604      freeMaps (&m);
     2605      free (m);
     2606      return 1;
     2607    }
    23832608    checkValidValue(request_inputs,&err,"service",(const char**)vvs,1);
    2384     printExceptionReportResponse (m, err);
    2385     freeMap(&err);
    2386     free(err);
    2387     if (count (request_inputs) == 1)
    2388       {
    2389         freeMap (&request_inputs);
    2390         free (request_inputs);
    2391       }
    2392     freeMaps (&m);
    2393     free (m);
    2394     return 1;
    2395   }
    2396   checkValidValue(request_inputs,&err,"service",(const char**)vvs,1);
    2397 
    2398   const char *vvv[]={
    2399     "1.0.0",
    2400     "2.0.0",
    2401     NULL
    2402   };
    2403   r_inputs = getMap (request_inputs, "Request");
    2404   if(r_inputs!=NULL)
    2405     REQUEST = zStrdup (r_inputs->value);
    2406   int reqId=-1;
    2407   if (strncasecmp (REQUEST, "GetCapabilities", 15) != 0){
    2408     checkValidValue(request_inputs,&err,"version",(const char**)vvv,1);
    2409     int j=0;
    2410     for(j=0;j<nbSupportedRequests;j++){
    2411       if(requests[vid][j]!=NULL && requests[vid][j+1]!=NULL){
    2412         if(j<nbReqIdentifier && strncasecmp(REQUEST,requests[vid][j+1],strlen(requests[vid][j+1]))==0){
    2413           checkValidValue(request_inputs,&err,"identifier",NULL,1);
    2414           reqId=j+1;
    2415           break;
    2416         }
    2417         else
    2418           if(j>=nbReqIdentifier && j<nbReqIdentifier+nbReqJob &&
    2419              strncasecmp(REQUEST,requests[vid][j+1],strlen(requests[vid][j+1]))==0){
    2420             checkValidValue(request_inputs,&err,"jobid",NULL,1);
     2609
     2610    const char *vvv[]={
     2611      "1.0.0",
     2612      "2.0.0",
     2613      NULL
     2614    };
     2615    r_inputs = getMap (request_inputs, "Request");
     2616    if(r_inputs!=NULL)
     2617      REQUEST = zStrdup (r_inputs->value);
     2618    int reqId=-1;
     2619    if (strncasecmp (REQUEST, "GetCapabilities", 15) != 0){
     2620      checkValidValue(request_inputs,&err,"version",(const char**)vvv,1);
     2621      int j=0;
     2622      for(j=0;j<nbSupportedRequests;j++){
     2623        if(requests[vid][j]!=NULL && requests[vid][j+1]!=NULL){
     2624          if(j<nbReqIdentifier && strncasecmp(REQUEST,requests[vid][j+1],strlen(requests[vid][j+1]))==0){
     2625            checkValidValue(request_inputs,&err,"identifier",NULL,1);
    24212626            reqId=j+1;
    24222627            break;
    24232628          }
    2424       }else
    2425         break;
    2426     }
    2427   }else{
    2428     checkValidValue(request_inputs,&err,"AcceptVersions",(const char**)vvv,-1);
    2429     map* version1=getMap(request_inputs,"AcceptVersions");
    2430     if(version1!=NULL){
    2431       if(strstr(version1->value,schemas[1][0])!=NULL){
    2432         addToMap(request_inputs,"version",schemas[1][0]);
    2433         setMapInMaps(m,"main","rversion",schemas[1][0]);
     2629          else
     2630            if(j>=nbReqIdentifier && j<nbReqIdentifier+nbReqJob &&
     2631               strncasecmp(REQUEST,requests[vid][j+1],strlen(requests[vid][j+1]))==0){
     2632              checkValidValue(request_inputs,&err,"jobid",NULL,1);
     2633              reqId=j+1;
     2634              break;
     2635            }
     2636        }else
     2637          break;
    24342638      }
    2435       else{
    2436         addToMap(request_inputs,"version",version1->value);
    2437         setMapInMaps(m,"main","rversion",version1->value);
     2639    }else{
     2640      checkValidValue(request_inputs,&err,"AcceptVersions",(const char**)vvv,-1);
     2641      map* version1=getMap(request_inputs,"AcceptVersions");
     2642      if(version1!=NULL){
     2643        if(strstr(version1->value,schemas[1][0])!=NULL){
     2644          addToMap(request_inputs,"version",schemas[1][0]);
     2645          setMapInMaps(m,"main","rversion",schemas[1][0]);
     2646        }
     2647        else{
     2648          addToMap(request_inputs,"version",version1->value);
     2649          setMapInMaps(m,"main","rversion",version1->value);
     2650        }
     2651        version=getMap(request_inputs,"version");
    24382652      }
    2439       version=getMap(request_inputs,"version");
    2440     }
    2441   }
    2442   if(err!=NULL){
    2443     printExceptionReportResponse (m, err);
    2444     freeMap(&err);
    2445     free(err);
    2446     if (count (request_inputs) == 1)
     2653    }
     2654    if(err!=NULL){
     2655      printExceptionReportResponse (m, err);
     2656      freeMap(&err);
     2657      free(err);
     2658      if (count (request_inputs) == 1)
     2659        {
     2660          freeMap (&request_inputs);
     2661          free (request_inputs);
     2662        }
     2663      free(REQUEST);
     2664      freeMaps (&m);
     2665      free (m);
     2666      return 1;
     2667    }
     2668
     2669    r_inputs = getMap (request_inputs, "serviceprovider");
     2670    if (r_inputs == NULL)
    24472671      {
    2448         freeMap (&request_inputs);
    2449         free (request_inputs);
     2672        addToMap (request_inputs, "serviceprovider", "");
    24502673      }
    2451     free(REQUEST);
    2452     freeMaps (&m);
    2453     free (m);
    2454     return 1;
    2455   }
    2456 
    2457   r_inputs = getMap (request_inputs, "serviceprovider");
    2458   if (r_inputs == NULL)
    2459     {
    2460       addToMap (request_inputs, "serviceprovider", "");
    2461     }
    2462 
    2463   maps *request_output_real_format = NULL;
    2464   map *tmpm = getMapFromMaps (m, "main", "serverAddress");
    2465   if (tmpm != NULL)
    2466     SERVICE_URL = zStrdup (tmpm->value);
    2467   else
    2468     SERVICE_URL = zStrdup (DEFAULT_SERVICE_URL);
    2469 
    2470 
    2471 
    2472   service *s1;
    2473   int scount = 0;
    2474 #ifdef DEBUG
    2475   dumpMap (r_inputs);
    2476 #endif
    2477 
    2478   if (strncasecmp (REQUEST, "GetCapabilities", 15) == 0)
    2479     {
    2480 #ifdef DEBUG
    2481       dumpMap (r_inputs);
    2482 #endif
    2483       xmlDocPtr doc = xmlNewDoc (BAD_CAST "1.0");
    2484       xmlNodePtr n=printGetCapabilitiesHeader(doc,m,(version!=NULL?version->value:"1.0.0"));
    2485       /**
    2486        * Here we need to close stdout to ensure that unsupported chars
    2487        * has been found in the zcfg and then printed on stdout
    2488        */
    2489       int saved_stdout = zDup (fileno (stdout));
    2490       zDup2 (fileno (stderr), fileno (stdout));
    2491 
    2492       maps* imports = getMaps(m, IMPORTSERVICE);
    2493       if (imports != NULL) {       
    2494         map* zcfg = imports->content;
     2674
     2675    map *tmpm = getMapFromMaps (m, "main", "serverAddress");
     2676    if (tmpm != NULL)
     2677      SERVICE_URL = zStrdup (tmpm->value);
     2678    else
     2679      SERVICE_URL = zStrdup (DEFAULT_SERVICE_URL);
     2680
     2681
     2682    int scount = 0;
     2683#ifdef DEBUG
     2684    dumpMap (r_inputs);
     2685#endif
     2686
     2687    if (strncasecmp (REQUEST, "GetCapabilities", 15) == 0)
     2688      {
     2689#ifdef DEBUG
     2690        dumpMap (r_inputs);
     2691#endif
     2692        xmlDocPtr doc = xmlNewDoc (BAD_CAST "1.0");
     2693        xmlNodePtr n=printGetCapabilitiesHeader(doc,m,(version!=NULL?version->value:"1.0.0"));
     2694        /**
     2695         * Here we need to close stdout to ensure that unsupported chars
     2696         * has been found in the zcfg and then printed on stdout
     2697         */
     2698        int saved_stdout = zDup (fileno (stdout));
     2699        zDup2 (fileno (stderr), fileno (stdout));
     2700
     2701        maps* imports = getMaps(m, IMPORTSERVICE);
     2702        if (imports != NULL) {       
     2703          map* zcfg = imports->content;
    24952704       
    2496         while (zcfg != NULL) {
    2497           if (zcfg->value != NULL) {
    2498             service* svc = (service*) malloc(SERVICE_SIZE);
    2499             if (svc == NULL || readServiceFile(m, zcfg->value, &svc, zcfg->name) < 0) {
    2500               // pass over silently
    2501               zcfg = zcfg->next;
    2502               continue;
     2705          while (zcfg != NULL) {
     2706            if (zcfg->value != NULL) {
     2707              service* svc = (service*) malloc(SERVICE_SIZE);
     2708              if (svc == NULL || readServiceFile(m, zcfg->value, &svc, zcfg->name) < 0) {
     2709                // pass over silently
     2710                zcfg = zcfg->next;
     2711                continue;
     2712              }
     2713              inheritance(zooRegistry, &svc);
     2714              printGetCapabilitiesForProcess(zooRegistry, m, doc, n, svc);
     2715              freeService(&svc);
     2716              free(svc);                             
    25032717            }
    2504             inheritance(zooRegistry, &svc);
    2505             printGetCapabilitiesForProcess(zooRegistry, m, doc, n, svc);
    2506             freeService(&svc);
    2507             free(svc);                             
     2718            zcfg = zcfg->next;
     2719          }           
     2720        }
     2721
     2722        if (int res =             
     2723            recursReaddirF (m, zooRegistry, doc, n, conf_dir, NULL, saved_stdout, 0,
     2724                            printGetCapabilitiesForProcess) < 0)
     2725          {
     2726            freeMaps (&m);
     2727            free (m);
     2728            if(zooRegistry!=NULL){
     2729              freeRegistry(&zooRegistry);
     2730              free(zooRegistry);
     2731            }
     2732            free (REQUEST);
     2733            free (SERVICE_URL);
     2734            fflush (stdout);
     2735            return res;
    25082736          }
    2509           zcfg = zcfg->next;
    2510         }           
     2737        fflush (stdout);
     2738        zDup2 (saved_stdout, fileno (stdout));
     2739#ifdef META_DB
     2740        fetchServicesFromDb(zooRegistry,m,doc,n,printGetCapabilitiesForProcess,1);
     2741        close_sql(m,0);
     2742#endif     
     2743        printDocument (m, doc, zGetpid ());
     2744        freeMaps (&m);
     2745        free (m);
     2746        if(zooRegistry!=NULL){
     2747          freeRegistry(&zooRegistry);
     2748          free(zooRegistry);
     2749        }
     2750        free (REQUEST);
     2751        free (SERVICE_URL);
     2752        fflush (stdout);
     2753        return 0;
    25112754      }
    2512 
    2513       if (int res =               
    2514           recursReaddirF (m, zooRegistry, doc, n, conf_dir, NULL, saved_stdout, 0,
    2515                           printGetCapabilitiesForProcess) < 0)
    2516         {
    2517           freeMaps (&m);
    2518           free (m);
    2519           if(zooRegistry!=NULL){
    2520             freeRegistry(&zooRegistry);
    2521             free(zooRegistry);
     2755    else
     2756      {
     2757        r_inputs = getMap (request_inputs, "JobId");
     2758        if(reqId>nbReqIdentifier){
     2759          if (strncasecmp (REQUEST, "GetStatus", 9) == 0 ||
     2760              strncasecmp (REQUEST, "GetResult", 9) == 0){
     2761            runGetStatus(m,r_inputs->value,REQUEST);
     2762#ifdef RELY_ON_DB
     2763            map* dsNb=getMapFromMaps(m,"lenv","ds_nb");
     2764            if(dsNb!=NULL && atoi(dsNb->value)>1)
     2765              close_sql(m,1);
     2766            close_sql(m,0);
     2767#endif
     2768         
     2769            freeMaps (&m);
     2770            free(m);
     2771            if(zooRegistry!=NULL){
     2772              freeRegistry(&zooRegistry);
     2773              free(zooRegistry);
     2774            }
     2775            free (REQUEST);
     2776            free (SERVICE_URL);
     2777            return 0;
    25222778          }
    2523           free (REQUEST);
    2524           free (SERVICE_URL);
    2525           fflush (stdout);
    2526           return res;
    2527         }
    2528       fflush (stdout);
    2529       zDup2 (saved_stdout, fileno (stdout));
     2779          else
     2780            if (strncasecmp (REQUEST, "Dismiss", strlen(REQUEST)) == 0){
     2781              runDismiss(m,r_inputs->value);
     2782              freeMaps (&m);
     2783              free (m);
     2784              if(zooRegistry!=NULL){
     2785                freeRegistry(&zooRegistry);
     2786                free(zooRegistry);
     2787              }
     2788              free (REQUEST);
     2789              free (SERVICE_URL);
     2790              return 0;
     2791           
     2792            }
     2793          return 0;
     2794        }
     2795        if(reqId<=nbReqIdentifier){
     2796          r_inputs = getMap (request_inputs, "Identifier");
     2797
     2798          struct dirent *dp;
     2799          DIR *dirp = opendir (conf_dir);
     2800          if (dirp == NULL)
     2801            {
     2802              errorException (m, _("The specified path does not exist."),
     2803                              "InternalError", NULL);
     2804              freeMaps (&m);
     2805              free (m);
     2806              if(zooRegistry!=NULL){
     2807                freeRegistry(&zooRegistry);
     2808                free(zooRegistry);
     2809              }
     2810              free (REQUEST);
     2811              free (SERVICE_URL);
     2812              return 0;
     2813            }
     2814          if (strncasecmp (REQUEST, "DescribeProcess", 15) == 0)
     2815            {
     2816              /**
     2817               * Loop over Identifier list
     2818               */
     2819              xmlDocPtr doc = xmlNewDoc (BAD_CAST "1.0");
     2820              r_inputs = NULL;
     2821              r_inputs = getMap (request_inputs, "version");
     2822#ifdef DEBUG
     2823              fprintf(stderr," ** DEBUG %s %d \n",__FILE__,__LINE__);
     2824              fflush(stderr);
     2825#endif
     2826              xmlNodePtr n = printWPSHeader(doc,m,"DescribeProcess",
     2827                                            root_nodes[vid][1],(version!=NULL?version->value:"1.0.0"),1);
     2828
     2829              r_inputs = getMap (request_inputs, "Identifier");
     2830
     2831              fetchServicesForDescription(zooRegistry, m, r_inputs->value,
     2832                                          printDescribeProcessForProcess,
     2833                                          (void*) doc, (void*) n, conf_dir,
     2834                                          request_inputs,printExceptionReportResponse);
     2835
     2836              printDocument (m, doc, zGetpid ());
     2837              freeMaps (&m);
     2838              free (m);
     2839              if(zooRegistry!=NULL){
     2840                freeRegistry(&zooRegistry);
     2841                free(zooRegistry);
     2842              }
     2843              free (REQUEST);
     2844              free (SERVICE_URL);
     2845              fflush (stdout);
    25302846#ifdef META_DB
    2531       fetchServicesFromDb(zooRegistry,m,doc,n,printGetCapabilitiesForProcess,1);
    2532       close_sql(m,0);
    2533 #endif     
    2534       printDocument (m, doc, zGetpid ());
     2847              close_sql(m,0);
     2848              //end_sql();
     2849#endif
     2850              return 0;
     2851            }
     2852          else if (strncasecmp (REQUEST, "Execute", strlen (REQUEST)) != 0)
     2853            {
     2854              map* version=getMapFromMaps(m,"main","rversion");
     2855              int vid=getVersionId(version->value);         
     2856              int len = 0;
     2857              int j = 0;
     2858              for(j=0;j<nbSupportedRequests;j++){
     2859                if(requests[vid][j]!=NULL)
     2860                  len+=strlen(requests[vid][j])+2;
     2861                else{
     2862                  len+=4;
     2863                  break;
     2864                }
     2865              }
     2866              char *tmpStr=(char*)malloc(len*sizeof(char));
     2867              int it=0;
     2868              for(j=0;j<nbSupportedRequests;j++){
     2869                if(requests[vid][j]!=NULL){
     2870                  if(it==0){
     2871                    sprintf(tmpStr,"%s",requests[vid][j]);
     2872                    it++;
     2873                  }else{
     2874                    char *tmpS=zStrdup(tmpStr);
     2875                    if(j+1<nbSupportedRequests && requests[vid][j+1]==NULL){
     2876                      sprintf(tmpStr,"%s and %s",tmpS,requests[vid][j]);
     2877                    }else{
     2878                      sprintf(tmpStr,"%s, %s",tmpS,requests[vid][j]);
     2879                 
     2880                    }
     2881                    free(tmpS);
     2882                  }
     2883                }
     2884                else{
     2885                  len+=4;
     2886                  break;
     2887                }
     2888              }
     2889              char* message=(char*)malloc((61+len)*sizeof(char));
     2890              sprintf(message,"The <request> value was not recognized. Allowed values are %s.",tmpStr);
     2891              errorException (m,_(message),"InvalidParameterValue", "request");
     2892#ifdef DEBUG
     2893              fprintf (stderr, "No request found %s", REQUEST);
     2894#endif
     2895              closedir (dirp);
     2896              freeMaps (&m);
     2897              free (m);
     2898              if(zooRegistry!=NULL){
     2899                freeRegistry(&zooRegistry);
     2900                free(zooRegistry);
     2901              }
     2902              free (REQUEST);
     2903              free (SERVICE_URL);
     2904              fflush (stdout);
     2905              return 0;
     2906            }
     2907          closedir (dirp);
     2908        }
     2909      }
     2910
     2911    map *postRequest = NULL;
     2912    postRequest = getMap (request_inputs, "xrequest");
     2913 
     2914    if(vid==1 && postRequest==NULL){
     2915      errorException (m,_("Unable to run Execute request using the GET HTTP method"),"InvalidParameterValue", "request"); 
    25352916      freeMaps (&m);
    25362917      free (m);
     
    25442925      return 0;
    25452926    }
    2546   else
    2547     {
    2548       r_inputs = getMap (request_inputs, "JobId");
    2549       if(reqId>nbReqIdentifier){
    2550         if (strncasecmp (REQUEST, "GetStatus", 9) == 0 ||
    2551             strncasecmp (REQUEST, "GetResult", 9) == 0){
    2552           runGetStatus(m,r_inputs->value,REQUEST);
    2553 #ifdef RELY_ON_DB
    2554           map* dsNb=getMapFromMaps(m,"lenv","ds_nb");
    2555           if(dsNb!=NULL && atoi(dsNb->value)>1)
    2556             close_sql(m,1);
    2557           close_sql(m,0);
    2558 #endif
    2559          
     2927    s1 = NULL;
     2928 
     2929    r_inputs = getMap (request_inputs, "Identifier");
     2930    map* import = getMapFromMaps (m, IMPORTSERVICE, r_inputs->value);
     2931    if (import != NULL && import->value != NULL) {
     2932      strncpy(tmps1, import->value, 1024);
     2933      setMapInMaps (m, "lenv", "Identifier", r_inputs->value);
     2934      setMapInMaps (m, "lenv", "oIdentifier", r_inputs->value);
     2935    }
     2936    else {
     2937      snprintf (tmps1, 1024, "%s/%s.zcfg", conf_dir, r_inputs->value);
     2938#ifdef DEBUG
     2939      fprintf (stderr, "Trying to load %s\n", tmps1);
     2940#endif
     2941      if (strstr (r_inputs->value, ".") != NULL)
     2942        {
     2943          char *identifier = zStrdup (r_inputs->value);
     2944          parseIdentifier (m, conf_dir, identifier, tmps1);
     2945          map *tmpMap = getMapFromMaps (m, "lenv", "metapath");
     2946          if (tmpMap != NULL)
     2947            addToMap (request_inputs, "metapath", tmpMap->value);
     2948          free (identifier);
     2949        }
     2950      else
     2951        {
     2952          setMapInMaps (m, "lenv", "Identifier", r_inputs->value);
     2953          setMapInMaps (m, "lenv", "oIdentifier", r_inputs->value);
     2954        }
     2955    }
     2956
     2957    r_inputs = getMapFromMaps (m, "lenv", "Identifier");
     2958 
     2959#ifdef META_DB
     2960    int metadb_id=_init_sql(m,"metadb");
     2961    //FAILED CONNECTING DB
     2962    if(getMapFromMaps(m,"lenv","dbIssue")!=NULL || metadb_id<0){
     2963      fprintf(stderr,"ERROR CONNECTING METADB\n");
     2964    }
     2965    if(metadb_id>=0)
     2966      s1=extractServiceFromDb(m,r_inputs->value,0);
     2967    //close_sql(m,0);
     2968    if(s1!=NULL){
     2969      inheritance(zooRegistry,&s1);
     2970#ifdef USE_HPC
     2971      addNestedOutputs(&s1);
     2972#endif
     2973      if(zooRegistry!=NULL){
     2974        freeRegistry(&zooRegistry);
     2975        free(zooRegistry);
     2976      }
     2977    }else /* Not found in MetaDB */{
     2978#endif
     2979      s1 = createService();
     2980      if (s1 == NULL)
     2981        {
    25602982          freeMaps (&m);
    2561           free(m);
     2983          free (m);
    25622984          if(zooRegistry!=NULL){
    25632985            freeRegistry(&zooRegistry);
     
    25662988          free (REQUEST);
    25672989          free (SERVICE_URL);
     2990          return errorException (m, _("Unable to allocate memory"),
     2991                                 "InternalError", NULL);
     2992        }
     2993
     2994      int saved_stdout = zDup (fileno (stdout));
     2995      zDup2 (fileno (stderr), fileno (stdout));
     2996      t = readServiceFile (m, tmps1, &s1, r_inputs->value);
     2997      if(t>=0){
     2998        inheritance(zooRegistry,&s1);
     2999#ifdef USE_HPC
     3000        addNestedOutputs(&s1);
     3001#endif
     3002      }
     3003      if(zooRegistry!=NULL){
     3004        freeRegistry(&zooRegistry);
     3005        free(zooRegistry);
     3006      }
     3007      fflush (stdout);
     3008      zDup2 (saved_stdout, fileno (stdout));
     3009      if (t < 0)
     3010        {
     3011          char *tmpMsg = (char *) malloc (2048 + strlen (r_inputs->value));
     3012          sprintf (tmpMsg,
     3013                   _
     3014                   ("The value for <identifier> seems to be wrong (%s). Please specify one of the processes in the list returned by a GetCapabilities request."),
     3015                   r_inputs->value);
     3016          errorException (m, tmpMsg, "InvalidParameterValue", "identifier");
     3017          free (tmpMsg);
     3018          free (s1);
     3019          freeMaps (&m);
     3020          free (m);
     3021          free (REQUEST);
     3022          free (SERVICE_URL);
    25683023          return 0;
    25693024        }
    2570         else
    2571           if (strncasecmp (REQUEST, "Dismiss", strlen(REQUEST)) == 0){
    2572             runDismiss(m,r_inputs->value);
     3025      zClose (saved_stdout);
     3026#ifdef META_DB
     3027    }
     3028#endif
     3029 
     3030#ifdef DEBUG
     3031    dumpService (s1);
     3032#endif
     3033    int j;
     3034
     3035
     3036    /**
     3037     * Create the input and output maps data structure
     3038     */
     3039    int i = 0;
     3040    HINTERNET res;
     3041    hInternet = InternetOpen (
     3042#ifndef WIN32
     3043                              (LPCTSTR)
     3044#endif
     3045                              "ZooWPSClient\0",
     3046                              INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
     3047
     3048#ifndef WIN32
     3049    if (!CHECK_INET_HANDLE (hInternet))
     3050      fprintf (stderr, "WARNING : hInternet handle failed to initialize");
     3051#endif
     3052    maps *tmpmaps = request_input_real_format;
     3053
     3054    if(parseRequest(&m,&request_inputs,s1,&request_input_real_format,&request_output_real_format,&hInternet)<0){
     3055      freeMaps (&m);
     3056      free (m);
     3057      free (REQUEST);
     3058      free (SERVICE_URL);
     3059      InternetCloseHandle (&hInternet);
     3060      freeService (&s1);
     3061      free (s1);
     3062      return 0;
     3063    }
     3064    //InternetCloseHandle (&hInternet);
     3065
     3066    initAllEnvironment(m,request_inputs,ntmp,"xrequest");
     3067
     3068
     3069#ifdef DEBUG
     3070    dumpMap (request_inputs);
     3071#endif
     3072
     3073    map *status = getMap (request_inputs, "status");
     3074    if(vid==0){
     3075      // Need to check if we need to fork to load a status enabled
     3076      r_inputs = NULL;
     3077      map *store = getMap (request_inputs, "storeExecuteResponse");
     3078      /**
     3079       * 05-007r7 WPS 1.0.0 page 57 :
     3080       * 'If status="true" and storeExecuteResponse is "false" then the service
     3081       * shall raise an exception.'
     3082       */
     3083      if (status != NULL && strcmp (status->value, "true") == 0 &&
     3084          store != NULL && strcmp (store->value, "false") == 0)
     3085        {
     3086          errorException (m,
     3087                          _
     3088                          ("The status parameter cannot be set to true if storeExecuteResponse is set to false. Please modify your request parameters."),
     3089                          "InvalidParameterValue", "storeExecuteResponse");
     3090          freeService (&s1);
     3091          free (s1);
     3092          freeMaps (&m);
     3093          free (m);
     3094       
     3095          freeMaps (&request_input_real_format);
     3096          free (request_input_real_format);
     3097       
     3098          freeMaps (&request_output_real_format);
     3099          free (request_output_real_format);
     3100
     3101          free (REQUEST);
     3102          free (SERVICE_URL);
     3103          return 1;
     3104        }
     3105      r_inputs = getMap (request_inputs, "storeExecuteResponse");
     3106    }else{
     3107      // Define status depending on the WPS 2.0.0 mode attribute
     3108      status = getMap (request_inputs, "mode");
     3109      map* mode=getMap(s1->content,"mode");
     3110      if(strcasecmp(status->value,"async")==0){
     3111        if(mode!=NULL && strcasecmp(mode->value,"async")==0)
     3112          addToMap(request_inputs,"status","true");
     3113        else{
     3114          if(mode!=NULL){
     3115            // see ref. http://docs.opengeospatial.org/is/14-065/14-065.html#61
     3116            errorException (m,_("The process does not permit the desired execution mode."),"NoSuchMode", mode->value); 
     3117            fflush (stdout);
    25733118            freeMaps (&m);
    25743119            free (m);
     
    25773122              free(zooRegistry);
    25783123            }
     3124            freeMaps (&request_input_real_format);
     3125            free (request_input_real_format);
     3126            freeMaps (&request_output_real_format);
     3127            free (request_output_real_format);
    25793128            free (REQUEST);
    25803129            free (SERVICE_URL);
    25813130            return 0;
    2582            
     3131          }else
     3132            addToMap(request_inputs,"status","true");
     3133        }
     3134      }
     3135      else{
     3136        if(strcasecmp(status->value,"auto")==0){
     3137          if(mode!=NULL){
     3138            if(strcasecmp(mode->value,"async")==0)
     3139              addToMap(request_inputs,"status","false");
     3140            else
     3141              addToMap(request_inputs,"status","true");
    25833142          }
    2584         return 0;
     3143          else
     3144            addToMap(request_inputs,"status","false");
     3145        }else
     3146          addToMap(request_inputs,"status","false");
    25853147      }
    2586       if(reqId<=nbReqIdentifier){
    2587         r_inputs = getMap (request_inputs, "Identifier");
    2588 
    2589         struct dirent *dp;
    2590         DIR *dirp = opendir (conf_dir);
    2591         if (dirp == NULL)
    2592           {
    2593             errorException (m, _("The specified path does not exist."),
    2594                             "InternalError", NULL);
    2595             freeMaps (&m);
    2596             free (m);
    2597             if(zooRegistry!=NULL){
    2598               freeRegistry(&zooRegistry);
    2599               free(zooRegistry);
    2600             }
    2601             free (REQUEST);
    2602             free (SERVICE_URL);
    2603             return 0;
    2604           }
    2605         if (strncasecmp (REQUEST, "DescribeProcess", 15) == 0)
    2606           {
    2607             /**
    2608              * Loop over Identifier list
    2609              */
    2610             xmlDocPtr doc = xmlNewDoc (BAD_CAST "1.0");
    2611             r_inputs = NULL;
    2612             r_inputs = getMap (request_inputs, "version");
    2613 #ifdef DEBUG
    2614             fprintf(stderr," ** DEBUG %s %d \n",__FILE__,__LINE__);
    2615             fflush(stderr);
    2616 #endif
    2617             xmlNodePtr n = printWPSHeader(doc,m,"DescribeProcess",
    2618                                           root_nodes[vid][1],(version!=NULL?version->value:"1.0.0"),1);
    2619 
    2620             r_inputs = getMap (request_inputs, "Identifier");
    2621 
    2622             fetchServicesForDescription(zooRegistry, m, r_inputs->value,
    2623                                         printDescribeProcessForProcess,
    2624                                         (void*) doc, (void*) n, conf_dir,
    2625                                         request_inputs,printExceptionReportResponse);
    2626 
    2627             printDocument (m, doc, zGetpid ());
    2628             freeMaps (&m);
    2629             free (m);
    2630             if(zooRegistry!=NULL){
    2631               freeRegistry(&zooRegistry);
    2632               free(zooRegistry);
    2633             }
    2634             free (REQUEST);
    2635             free (SERVICE_URL);
    2636             fflush (stdout);
    2637 #ifdef META_DB
    2638             close_sql(m,0);
    2639             //end_sql();
    2640 #endif
    2641             return 0;
    2642           }
    2643         else if (strncasecmp (REQUEST, "Execute", strlen (REQUEST)) != 0)
    2644           {
    2645             map* version=getMapFromMaps(m,"main","rversion");
    2646             int vid=getVersionId(version->value);           
    2647             int len = 0;
    2648             int j = 0;
    2649             for(j=0;j<nbSupportedRequests;j++){
    2650               if(requests[vid][j]!=NULL)
    2651                 len+=strlen(requests[vid][j])+2;
    2652               else{
    2653                 len+=4;
    2654                 break;
    2655               }
    2656             }
    2657             char *tmpStr=(char*)malloc(len*sizeof(char));
    2658             int it=0;
    2659             for(j=0;j<nbSupportedRequests;j++){
    2660               if(requests[vid][j]!=NULL){
    2661                 if(it==0){
    2662                   sprintf(tmpStr,"%s",requests[vid][j]);
    2663                   it++;
    2664                 }else{
    2665                   char *tmpS=zStrdup(tmpStr);
    2666                   if(j+1<nbSupportedRequests && requests[vid][j+1]==NULL){
    2667                     sprintf(tmpStr,"%s and %s",tmpS,requests[vid][j]);
    2668                   }else{
    2669                     sprintf(tmpStr,"%s, %s",tmpS,requests[vid][j]);
    2670                  
    2671                   }
    2672                   free(tmpS);
    2673                 }
    2674               }
    2675               else{
    2676                 len+=4;
    2677                 break;
    2678               }
    2679             }
    2680             char* message=(char*)malloc((61+len)*sizeof(char));
    2681             sprintf(message,"The <request> value was not recognized. Allowed values are %s.",tmpStr);
    2682             errorException (m,_(message),"InvalidParameterValue", "request");
    2683 #ifdef DEBUG
    2684             fprintf (stderr, "No request found %s", REQUEST);
    2685 #endif
    2686             closedir (dirp);
    2687             freeMaps (&m);
    2688             free (m);
    2689             if(zooRegistry!=NULL){
    2690               freeRegistry(&zooRegistry);
    2691               free(zooRegistry);
    2692             }
    2693             free (REQUEST);
    2694             free (SERVICE_URL);
    2695             fflush (stdout);
    2696             return 0;
    2697           }
    2698         closedir (dirp);
    2699       }
    2700     }
    2701 
    2702   map *postRequest = NULL;
    2703   postRequest = getMap (request_inputs, "xrequest");
    2704  
    2705   if(vid==1 && postRequest==NULL){
    2706     errorException (m,_("Unable to run Execute request using the GET HTTP method"),"InvalidParameterValue", "request"); 
    2707     freeMaps (&m);
    2708     free (m);
    2709     if(zooRegistry!=NULL){
    2710       freeRegistry(&zooRegistry);
    2711       free(zooRegistry);
    2712     }
    2713     free (REQUEST);
    2714     free (SERVICE_URL);
    2715     fflush (stdout);
    2716     return 0;
    2717   }
    2718   s1 = NULL;
    2719  
    2720   r_inputs = getMap (request_inputs, "Identifier");
    2721   map* import = getMapFromMaps (m, IMPORTSERVICE, r_inputs->value);
    2722   if (import != NULL && import->value != NULL) {
    2723     strncpy(tmps1, import->value, 1024);
    2724     setMapInMaps (m, "lenv", "Identifier", r_inputs->value);
    2725     setMapInMaps (m, "lenv", "oIdentifier", r_inputs->value);
    2726   }
    2727   else {
    2728     snprintf (tmps1, 1024, "%s/%s.zcfg", conf_dir, r_inputs->value);
    2729 #ifdef DEBUG
    2730     fprintf (stderr, "Trying to load %s\n", tmps1);
    2731 #endif
    2732     if (strstr (r_inputs->value, ".") != NULL)
     3148      status = getMap (request_inputs, "status");
     3149    }
     3150
     3151    if (status != NULL)
     3152      if (strcasecmp (status->value, "false") == 0)
     3153        status = NULLMAP;
     3154    if (status == NULLMAP)
    27333155      {
    2734         char *identifier = zStrdup (r_inputs->value);
    2735         parseIdentifier (m, conf_dir, identifier, tmps1);
    2736         map *tmpMap = getMapFromMaps (m, "lenv", "metapath");
    2737         if (tmpMap != NULL)
    2738           addToMap (request_inputs, "metapath", tmpMap->value);
    2739         free (identifier);
    2740       }
    2741     else
    2742       {
    2743         setMapInMaps (m, "lenv", "Identifier", r_inputs->value);
    2744         setMapInMaps (m, "lenv", "oIdentifier", r_inputs->value);
    2745       }
    2746   }
    2747 
    2748   r_inputs = getMapFromMaps (m, "lenv", "Identifier");
    2749  
    2750 #ifdef META_DB
    2751   int metadb_id=_init_sql(m,"metadb");
    2752   //FAILED CONNECTING DB
    2753   if(getMapFromMaps(m,"lenv","dbIssue")!=NULL || metadb_id<0){
    2754     fprintf(stderr,"ERROR CONNECTING METADB\n");
    2755   }
    2756   if(metadb_id>=0)
    2757     s1=extractServiceFromDb(m,r_inputs->value,0);
    2758   //close_sql(m,0);
    2759   if(s1!=NULL){
    2760     inheritance(zooRegistry,&s1);
    2761 #ifdef USE_HPC
    2762     addNestedOutputs(&s1);
    2763 #endif
    2764     if(zooRegistry!=NULL){
    2765       freeRegistry(&zooRegistry);
    2766       free(zooRegistry);
    2767     }
    2768   }else /* Not found in MetaDB */{
    2769 #endif
    2770     s1 = createService();
    2771     if (s1 == NULL)
    2772       {
    2773         freeMaps (&m);
    2774         free (m);
    2775         if(zooRegistry!=NULL){
    2776           freeRegistry(&zooRegistry);
    2777           free(zooRegistry);
    2778         }
    2779         free (REQUEST);
    2780         free (SERVICE_URL);
    2781         return errorException (m, _("Unable to allocate memory"),
    2782                                "InternalError", NULL);
    2783       }
    2784 
    2785     int saved_stdout = zDup (fileno (stdout));
    2786     zDup2 (fileno (stderr), fileno (stdout));
    2787     t = readServiceFile (m, tmps1, &s1, r_inputs->value);
    2788     if(t>=0){
    2789       inheritance(zooRegistry,&s1);
    2790 #ifdef USE_HPC
    2791       addNestedOutputs(&s1);
    2792 #endif
    2793     }
    2794     if(zooRegistry!=NULL){
    2795       freeRegistry(&zooRegistry);
    2796       free(zooRegistry);
    2797     }
    2798     fflush (stdout);
    2799     zDup2 (saved_stdout, fileno (stdout));
    2800     if (t < 0)
    2801       {
    2802         char *tmpMsg = (char *) malloc (2048 + strlen (r_inputs->value));
    2803         sprintf (tmpMsg,
    2804                  _
    2805                  ("The value for <identifier> seems to be wrong (%s). Please specify one of the processes in the list returned by a GetCapabilities request."),
    2806                  r_inputs->value);
    2807         errorException (m, tmpMsg, "InvalidParameterValue", "identifier");
    2808         free (tmpMsg);
    2809         free (s1);
    2810         freeMaps (&m);
    2811         free (m);
    2812         free (REQUEST);
    2813         free (SERVICE_URL);
    2814         return 0;
    2815       }
    2816     zClose (saved_stdout);
    2817 #ifdef META_DB
    2818   }
    2819 #endif
    2820  
    2821 #ifdef DEBUG
    2822   dumpService (s1);
    2823 #endif
    2824   int j;
    2825 
    2826 
    2827   /**
    2828    * Create the input and output maps data structure
    2829    */
    2830   int i = 0;
    2831   HINTERNET hInternet;
    2832   HINTERNET res;
    2833   hInternet = InternetOpen (
    2834 #ifndef WIN32
    2835                             (LPCTSTR)
    2836 #endif
    2837                             "ZooWPSClient\0",
    2838                             INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
    2839 
    2840 #ifndef WIN32
    2841   if (!CHECK_INET_HANDLE (hInternet))
    2842     fprintf (stderr, "WARNING : hInternet handle failed to initialize");
    2843 #endif
    2844   maps *request_input_real_format = NULL;
    2845   maps *tmpmaps = request_input_real_format;
    2846 
    2847   if(parseRequest(&m,&request_inputs,s1,&request_input_real_format,&request_output_real_format,&hInternet)<0){
    2848     freeMaps (&m);
    2849     free (m);
    2850     free (REQUEST);
    2851     free (SERVICE_URL);
    2852     InternetCloseHandle (&hInternet);
    2853     freeService (&s1);
    2854     free (s1);
    2855     return 0;
    2856   }
    2857   //InternetCloseHandle (&hInternet);
    2858 
    2859   initAllEnvironment(m,request_inputs,ntmp,"xrequest");
    2860 
    2861 
    2862 #ifdef DEBUG
    2863   dumpMap (request_inputs);
    2864 #endif
    2865 
    2866   map *status = getMap (request_inputs, "status");
    2867   if(vid==0){
    2868     // Need to check if we need to fork to load a status enabled
    2869     r_inputs = NULL;
    2870     map *store = getMap (request_inputs, "storeExecuteResponse");
    2871     /**
    2872      * 05-007r7 WPS 1.0.0 page 57 :
    2873      * 'If status="true" and storeExecuteResponse is "false" then the service
    2874      * shall raise an exception.'
    2875      */
    2876     if (status != NULL && strcmp (status->value, "true") == 0 &&
    2877         store != NULL && strcmp (store->value, "false") == 0)
    2878       {
    2879         errorException (m,
    2880                         _
    2881                         ("The status parameter cannot be set to true if storeExecuteResponse is set to false. Please modify your request parameters."),
    2882                         "InvalidParameterValue", "storeExecuteResponse");
    2883         freeService (&s1);
    2884         free (s1);
    2885         freeMaps (&m);
    2886         free (m);
    2887        
    2888         freeMaps (&request_input_real_format);
    2889         free (request_input_real_format);
    2890        
    2891         freeMaps (&request_output_real_format);
    2892         free (request_output_real_format);
    2893 
    2894         free (REQUEST);
    2895         free (SERVICE_URL);
    2896         return 1;
    2897       }
    2898     r_inputs = getMap (request_inputs, "storeExecuteResponse");
    2899   }else{
    2900     // Define status depending on the WPS 2.0.0 mode attribute
    2901     status = getMap (request_inputs, "mode");
    2902     map* mode=getMap(s1->content,"mode");
    2903     if(strcasecmp(status->value,"async")==0){
    2904       if(mode!=NULL && strcasecmp(mode->value,"async")==0)
    2905         addToMap(request_inputs,"status","true");
    2906       else{
    2907         if(mode!=NULL){
    2908           // see ref. http://docs.opengeospatial.org/is/14-065/14-065.html#61
    2909           errorException (m,_("The process does not permit the desired execution mode."),"NoSuchMode", mode->value); 
    2910           fflush (stdout);
     3156        if(validateRequest(&m,s1,request_inputs, &request_input_real_format,&request_output_real_format,&hInternet)<0){
     3157          freeService (&s1);
     3158          free (s1);
    29113159          freeMaps (&m);
    29123160          free (m);
    2913           if(zooRegistry!=NULL){
    2914             freeRegistry(&zooRegistry);
    2915             free(zooRegistry);
    2916           }
     3161          free (REQUEST);
     3162          free (SERVICE_URL);
    29173163          freeMaps (&request_input_real_format);
    29183164          free (request_input_real_format);
    29193165          freeMaps (&request_output_real_format);
    29203166          free (request_output_real_format);
    2921           free (REQUEST);
    2922           free (SERVICE_URL);
    2923           return 0;
    2924         }else
    2925           addToMap(request_inputs,"status","true");
     3167          freeMaps (&tmpmaps);
     3168          free (tmpmaps);
     3169          return -1;
     3170        }
     3171        map* testMap=getMapFromMaps(m,"main","memory");
     3172        if(testMap==NULL || strcasecmp(testMap->value,"load")!=0)
     3173          dumpMapsValuesToFiles(&m,&request_input_real_format);
     3174        loadServiceAndRun (&m, s1, request_inputs, &request_input_real_format,
     3175                           &request_output_real_format, &eres);   
     3176
     3177#ifdef META_DB
     3178        close_sql(m,0);     
     3179#endif     
    29263180      }
    2927     }
    2928     else{
    2929       if(strcasecmp(status->value,"auto")==0){
    2930         if(mode!=NULL){
    2931           if(strcasecmp(mode->value,"async")==0)
    2932             addToMap(request_inputs,"status","false");
    2933           else
    2934             addToMap(request_inputs,"status","true");
    2935         }
     3181    else
     3182      {
     3183        int pid;
     3184#ifdef DEBUG
     3185        fprintf (stderr, "\nPID : %d\n", cpid);
     3186#endif
     3187#ifndef WIN32
     3188        pid = fork ();
     3189#else
     3190        if (cgiSid == NULL)
     3191          {
     3192            createProcess (m, request_inputs, s1, NULL, cpid,
     3193                           request_input_real_format,
     3194                           request_output_real_format);
     3195            pid = cpid;
     3196          }
    29363197        else
    2937           addToMap(request_inputs,"status","false");
    2938       }else
    2939         addToMap(request_inputs,"status","false");
    2940     }
    2941     status = getMap (request_inputs, "status");
    2942   }
    2943 
    2944   int eres = SERVICE_STARTED;
    2945   int cpid = zGetpid ();
    2946 
    2947   maps* bmap=NULL;
    2948   char *fbkp, *fbkpid, *fbkpres, *fbkp1, *flog;
    2949   FILE *f0, *f1;
    2950   if (status != NULL)
    2951     if (strcasecmp (status->value, "false") == 0)
    2952       status = NULLMAP;
    2953   if (status == NULLMAP)
    2954     {
    2955       if(validateRequest(&m,s1,request_inputs, &request_input_real_format,&request_output_real_format,&hInternet)<0){
    2956         freeService (&s1);
    2957         free (s1);
    2958         freeMaps (&m);
    2959         free (m);
    2960         free (REQUEST);
    2961         free (SERVICE_URL);
    2962         freeMaps (&request_input_real_format);
    2963         free (request_input_real_format);
    2964         freeMaps (&request_output_real_format);
    2965         free (request_output_real_format);
    2966         freeMaps (&tmpmaps);
    2967         free (tmpmaps);
    2968         return -1;
    2969       }
    2970       map* testMap=getMapFromMaps(m,"main","memory");
    2971       if(testMap==NULL || strcasecmp(testMap->value,"load")!=0)
    2972         dumpMapsValuesToFiles(&m,&request_input_real_format);
    2973       loadServiceAndRun (&m, s1, request_inputs, &request_input_real_format,
    2974                          &request_output_real_format, &eres);     
    2975 
    2976 #ifdef META_DB
    2977       close_sql(m,0);     
    2978 #endif     
    2979     }
    2980   else
    2981     {
    2982       int pid;
    2983 #ifdef DEBUG
    2984       fprintf (stderr, "\nPID : %d\n", cpid);
    2985 #endif
     3198          {
     3199            pid = 0;
     3200            cpid = atoi (cgiSid);
     3201            updateStatus(m,0,_("Initializing"));
     3202          }
     3203#endif
     3204        if (pid > 0)
     3205          {
     3206            //
     3207            // dady :
     3208            // set status to SERVICE_ACCEPTED
     3209            //
     3210#ifdef DEBUG
     3211            fprintf (stderr, "father pid continue (origin %d) %d ...\n", cpid,
     3212                     zGetpid ());
     3213#endif
     3214            eres = SERVICE_ACCEPTED;
     3215          }
     3216        else if (pid == 0)
     3217          {
     3218            eres = SERVICE_ACCEPTED;
     3219            //
     3220            // son : have to close the stdout, stdin and stderr to let the parent
     3221            // process answer to http client.
     3222            //
     3223            map* usid = getMapFromMaps (m, "lenv", "uusid");
     3224            map* tmpm = getMapFromMaps (m, "lenv", "osid");
     3225            int cpid = atoi (tmpm->value);
     3226            pid=cpid;
     3227            r_inputs = getMapFromMaps (m, "main", "tmpPath");
     3228            setMapInMaps (m, "lenv", "async","true");
     3229            map* r_inputs1 = createMap("ServiceName", s1->name);
     3230
     3231            // Create the filename for the result file (.res)
     3232            fbkpres =
     3233              (char *)
     3234              malloc ((strlen (r_inputs->value) +
     3235                       strlen (usid->value) + 7) * sizeof (char));                   
     3236            sprintf (fbkpres, "%s/%s.res", r_inputs->value, usid->value);
     3237            bmap = createMaps("status");
     3238            bmap->content=createMap("usid",usid->value);
     3239            addToMap(bmap->content,"sid",tmpm->value);
     3240            addIntToMap(bmap->content,"pid",zGetpid());
     3241         
     3242            // Create PID file referencing the OS process identifier
     3243            fbkpid =
     3244              (char *)
     3245              malloc ((strlen (r_inputs->value) +
     3246                       strlen (usid->value) + 7) * sizeof (char));
     3247            sprintf (fbkpid, "%s/%s.pid", r_inputs->value, usid->value);
     3248            setMapInMaps (m, "lenv", "file.pid", fbkpid);
     3249
     3250            f0 = freopen (fbkpid, "w+",stdout);
     3251            printf("%d",zGetpid());
     3252            fflush(stdout);
     3253
     3254            // Create SID file referencing the semaphore name
     3255            fbkp =
     3256              (char *)
     3257              malloc ((strlen (r_inputs->value) + strlen (r_inputs1->value) +
     3258                       strlen (usid->value) + 7) * sizeof (char));
     3259            sprintf (fbkp, "%s/%s.sid", r_inputs->value, usid->value);
     3260            setMapInMaps (m, "lenv", "file.sid", fbkp);
     3261            FILE* f2 = freopen (fbkp, "w+",stdout);
     3262            printf("%s",tmpm->value);
     3263            fflush(f2);
     3264            free(fbkp);
     3265
     3266            fbkp =
     3267              (char *)
     3268              malloc ((strlen (r_inputs->value) + strlen (r_inputs1->value) +
     3269                       strlen (usid->value) + 7) * sizeof (char));
     3270            sprintf (fbkp, "%s/%s_%s.xml", r_inputs->value, r_inputs1->value,
     3271                     usid->value);
     3272            setMapInMaps (m, "lenv", "file.responseInit", fbkp);
     3273            flog =
     3274              (char *)
     3275              malloc ((strlen (r_inputs->value) + strlen (r_inputs1->value) +
     3276                       strlen (usid->value) + 13) * sizeof (char));
     3277            sprintf (flog, "%s/%s_%s_error.log", r_inputs->value,
     3278                     r_inputs1->value, usid->value);
     3279            setMapInMaps (m, "lenv", "file.log", flog);
     3280#ifdef DEBUG
     3281            fprintf (stderr, "RUN IN BACKGROUND MODE \n");
     3282            fprintf (stderr, "son pid continue (origin %d) %d ...\n", cpid,
     3283                     zGetpid ());
     3284            fprintf (stderr, "\nFILE TO STORE DATA %s\n", r_inputs->value);
     3285#endif
     3286            freopen (flog, "w+", stderr);
     3287            fflush (stderr);
     3288            f0 = freopen (fbkp, "w+", stdout);
     3289            rewind (stdout);
    29863290#ifndef WIN32
    2987       pid = fork ();
     3291            fclose (stdin);
     3292#endif
     3293#ifdef RELY_ON_DB
     3294            init_sql(m);
     3295            recordServiceStatus(m);
     3296#endif
     3297#ifdef USE_CALLBACK
     3298            invokeCallback(m,NULL,NULL,0,0);
     3299#endif
     3300            if(vid==0){
     3301              //
     3302              // set status to SERVICE_STARTED and flush stdout to ensure full
     3303              // content was outputed (the file used to store the ResponseDocument).
     3304              // Then, rewind stdout to restart writing from the begining of the file.
     3305              // This way, the data will be updated at the end of the process run.
     3306              //
     3307              printProcessResponse (m, request_inputs, cpid, s1, r_inputs1->value,
     3308                                    SERVICE_STARTED, request_input_real_format,
     3309                                    request_output_real_format);
     3310              fflush (stdout);
     3311#ifdef RELY_ON_DB
     3312              recordResponse(m,fbkp);
     3313#endif
     3314            }
     3315
     3316            fflush (stderr);
     3317
     3318            fbkp1 =
     3319              (char *)
     3320              malloc ((strlen (r_inputs->value) + strlen (r_inputs1->value) +
     3321                       strlen (usid->value) + 13) * sizeof (char));
     3322            sprintf (fbkp1, "%s/%s_final_%s.xml", r_inputs->value,
     3323                     r_inputs1->value, usid->value);
     3324            setMapInMaps (m, "lenv", "file.responseFinal", fbkp1);
     3325
     3326            f1 = freopen (fbkp1, "w+", stdout);
     3327
     3328            map* serviceTypeMap=getMap(s1->content,"serviceType");
     3329            if(serviceTypeMap!=NULL)
     3330              setMapInMaps (m, "lenv", "serviceType", serviceTypeMap->value);
     3331
     3332            char *flenv =
     3333              (char *)
     3334              malloc ((strlen (r_inputs->value) +
     3335                       strlen (usid->value) + 12) * sizeof (char));
     3336            sprintf (flenv, "%s/%s_lenv.cfg", r_inputs->value, usid->value);
     3337            maps* lenvMaps=getMaps(m,"lenv");
     3338            dumpMapsToFile(lenvMaps,flenv,0);
     3339            free(flenv);
     3340
     3341#ifdef USE_CALLBACK
     3342            invokeCallback(m,request_input_real_format,NULL,1,0);
     3343#endif
     3344            if(validateRequest(&m,s1,request_inputs, &request_input_real_format,&request_output_real_format,&hInternet)<0){
     3345              freeService (&s1);
     3346              free (s1);
     3347              fflush (stdout);
     3348              fflush (stderr);
     3349              fclose (f0);
     3350              fclose (f1);
     3351              if(dumpBackFinalFile(m,fbkp,fbkp1)<0)
     3352                return -1;
     3353#ifndef RELY_ON_DB
     3354              dumpMapsToFile(bmap,fbkpres,1);
     3355              removeShmLock (m, 1);
    29883356#else
    2989       if (cgiSid == NULL)
    2990         {
    2991           createProcess (m, request_inputs, s1, NULL, cpid,
    2992                          request_input_real_format,
    2993                          request_output_real_format);
    2994           pid = cpid;
    2995         }
    2996       else
    2997         {
    2998           pid = 0;
    2999           cpid = atoi (cgiSid);
    3000           updateStatus(m,0,_("Initializing"));
    3001         }
    3002 #endif
    3003       if (pid > 0)
    3004         {
    3005           //
    3006           // dady :
    3007           // set status to SERVICE_ACCEPTED
    3008           //
    3009 #ifdef DEBUG
    3010           fprintf (stderr, "father pid continue (origin %d) %d ...\n", cpid,
    3011                    zGetpid ());
    3012 #endif
    3013           eres = SERVICE_ACCEPTED;
    3014         }
    3015       else if (pid == 0)
    3016         {
    3017           eres = SERVICE_ACCEPTED;
    3018           //
    3019           // son : have to close the stdout, stdin and stderr to let the parent
    3020           // process answer to http client.
    3021           //
    3022           map* usid = getMapFromMaps (m, "lenv", "uusid");
    3023           map* tmpm = getMapFromMaps (m, "lenv", "osid");
    3024           int cpid = atoi (tmpm->value);
    3025           pid=cpid;
    3026           r_inputs = getMapFromMaps (m, "main", "tmpPath");
    3027           setMapInMaps (m, "lenv", "async","true");
    3028           map* r_inputs1 = createMap("ServiceName", s1->name);
    3029 
    3030           // Create the filename for the result file (.res)
    3031           fbkpres =
    3032             (char *)
    3033             malloc ((strlen (r_inputs->value) +
    3034                      strlen (usid->value) + 7) * sizeof (char));                   
    3035           sprintf (fbkpres, "%s/%s.res", r_inputs->value, usid->value);
    3036           bmap = createMaps("status");
    3037           bmap->content=createMap("usid",usid->value);
    3038           addToMap(bmap->content,"sid",tmpm->value);
    3039           addIntToMap(bmap->content,"pid",zGetpid());
    3040          
    3041           // Create PID file referencing the OS process identifier
    3042           fbkpid =
    3043             (char *)
    3044             malloc ((strlen (r_inputs->value) +
    3045                      strlen (usid->value) + 7) * sizeof (char));
    3046           sprintf (fbkpid, "%s/%s.pid", r_inputs->value, usid->value);
    3047           setMapInMaps (m, "lenv", "file.pid", fbkpid);
    3048 
    3049           f0 = freopen (fbkpid, "w+",stdout);
    3050           printf("%d",zGetpid());
    3051           fflush(stdout);
    3052 
    3053           // Create SID file referencing the semaphore name
    3054           fbkp =
    3055             (char *)
    3056             malloc ((strlen (r_inputs->value) + strlen (r_inputs1->value) +
    3057                      strlen (usid->value) + 7) * sizeof (char));
    3058           sprintf (fbkp, "%s/%s.sid", r_inputs->value, usid->value);
    3059           setMapInMaps (m, "lenv", "file.sid", fbkp);
    3060           FILE* f2 = freopen (fbkp, "w+",stdout);
    3061           printf("%s",tmpm->value);
    3062           fflush(f2);
    3063           free(fbkp);
    3064 
    3065           fbkp =
    3066             (char *)
    3067             malloc ((strlen (r_inputs->value) + strlen (r_inputs1->value) +
    3068                      strlen (usid->value) + 7) * sizeof (char));
    3069           sprintf (fbkp, "%s/%s_%s.xml", r_inputs->value, r_inputs1->value,
    3070                    usid->value);
    3071           setMapInMaps (m, "lenv", "file.responseInit", fbkp);
    3072           flog =
    3073             (char *)
    3074             malloc ((strlen (r_inputs->value) + strlen (r_inputs1->value) +
    3075                      strlen (usid->value) + 13) * sizeof (char));
    3076           sprintf (flog, "%s/%s_%s_error.log", r_inputs->value,
    3077                    r_inputs1->value, usid->value);
    3078           setMapInMaps (m, "lenv", "file.log", flog);
    3079 #ifdef DEBUG
    3080           fprintf (stderr, "RUN IN BACKGROUND MODE \n");
    3081           fprintf (stderr, "son pid continue (origin %d) %d ...\n", cpid,
    3082                    zGetpid ());
    3083           fprintf (stderr, "\nFILE TO STORE DATA %s\n", r_inputs->value);
    3084 #endif
    3085           freopen (flog, "w+", stderr);
    3086           fflush (stderr);
    3087           f0 = freopen (fbkp, "w+", stdout);
    3088           rewind (stdout);
    3089 #ifndef WIN32
    3090           fclose (stdin);
    3091 #endif
    3092 #ifdef RELY_ON_DB
    3093           init_sql(m);
    3094           recordServiceStatus(m);
    3095 #endif
     3357              recordResponse(m,fbkp1);
    30963358#ifdef USE_CALLBACK
    3097           invokeCallback(m,NULL,NULL,0,0);
    3098 #endif
    3099           if(vid==0){
    3100             //
    3101             // set status to SERVICE_STARTED and flush stdout to ensure full
    3102             // content was outputed (the file used to store the ResponseDocument).
    3103             // Then, rewind stdout to restart writing from the begining of the file.
    3104             // This way, the data will be updated at the end of the process run.
    3105             //
    3106             printProcessResponse (m, request_inputs, cpid, s1, r_inputs1->value,
    3107                                   SERVICE_STARTED, request_input_real_format,
    3108                                   request_output_real_format);
    3109             fflush (stdout);
    3110 #ifdef RELY_ON_DB
    3111             recordResponse(m,fbkp);
    3112 #endif
    3113           }
    3114 
    3115           fflush (stderr);
    3116 
    3117           fbkp1 =
    3118             (char *)
    3119             malloc ((strlen (r_inputs->value) + strlen (r_inputs1->value) +
    3120                      strlen (usid->value) + 13) * sizeof (char));
    3121           sprintf (fbkp1, "%s/%s_final_%s.xml", r_inputs->value,
    3122                    r_inputs1->value, usid->value);
    3123           setMapInMaps (m, "lenv", "file.responseFinal", fbkp1);
    3124 
    3125           f1 = freopen (fbkp1, "w+", stdout);
    3126 
    3127           map* serviceTypeMap=getMap(s1->content,"serviceType");
    3128           if(serviceTypeMap!=NULL)
    3129             setMapInMaps (m, "lenv", "serviceType", serviceTypeMap->value);
    3130 
    3131           char *flenv =
    3132             (char *)
    3133             malloc ((strlen (r_inputs->value) +
    3134                      strlen (usid->value) + 12) * sizeof (char));
    3135           sprintf (flenv, "%s/%s_lenv.cfg", r_inputs->value, usid->value);
    3136           maps* lenvMaps=getMaps(m,"lenv");
    3137           dumpMapsToFile(lenvMaps,flenv,0);
    3138           free(flenv);
    3139 
    3140 #ifdef USE_CALLBACK
    3141           invokeCallback(m,request_input_real_format,NULL,1,0);
    3142 #endif
    3143           if(validateRequest(&m,s1,request_inputs, &request_input_real_format,&request_output_real_format,&hInternet)<0){
    3144             freeService (&s1);
    3145             free (s1);
    3146             fflush (stdout);
    3147             fflush (stderr);
    3148             fclose (f0);
    3149             fclose (f1);
    3150             if(dumpBackFinalFile(m,fbkp,fbkp1)<0)
    3151               return -1;
    3152 #ifndef RELY_ON_DB
    3153             dumpMapsToFile(bmap,fbkpres,1);
    3154             removeShmLock (m, 1);
    3155 #else
    3156             recordResponse(m,fbkp1);
    3157 #ifdef USE_CALLBACK
    3158             invokeCallback(m,NULL,NULL,7,0);
    3159 #endif
    3160 #endif
    3161             zUnlink (fbkpid);
    3162             unhandleStatus (m);
     3359              invokeCallback(m,NULL,NULL,7,0);
     3360#endif
     3361#endif
     3362              zUnlink (fbkpid);
     3363              unhandleStatus (m);
    31633364#ifdef RELY_ON_DB
    31643365#ifdef META_DB
    3165             cleanupCallbackThreads();
    3166             close_sql(m,1);
    3167 #endif
    3168             close_sql(m,0);
    3169 #endif
    3170             freeMaps (&m);
    3171             free (m);
    3172             free (REQUEST);
    3173             free (SERVICE_URL);
    3174             freeMaps (&request_input_real_format);
    3175             free (request_input_real_format);
    3176             freeMaps (&request_output_real_format);
    3177             free (request_output_real_format);
    3178             freeMaps (&tmpmaps);
    3179             free (tmpmaps);
    3180             return -1;
     3366              cleanupCallbackThreads();
     3367              close_sql(m,1);
     3368#endif
     3369              close_sql(m,0);
     3370#endif
     3371              freeMaps (&m);
     3372              free (m);
     3373              free (REQUEST);
     3374              free (SERVICE_URL);
     3375              freeMaps (&request_input_real_format);
     3376              free (request_input_real_format);
     3377              freeMaps (&request_output_real_format);
     3378              free (request_output_real_format);
     3379              freeMaps (&tmpmaps);
     3380              free (tmpmaps);
     3381              return -1;
     3382            }
     3383            if(getMapFromMaps(m,"lenv","mapError")!=NULL){
     3384              setMapInMaps(m,"lenv","message",_("Issue with geographic data"));
     3385#ifdef USE_CALLBACK
     3386              invokeCallback(m,NULL,NULL,7,0);
     3387#endif
     3388              eres=-1;//SERVICE_FAILED;
     3389            }else{
     3390              map* testMap=getMapFromMaps(m,"main","memory");
     3391              if(testMap==NULL || strcasecmp(testMap->value,"load")!=0)
     3392                dumpMapsValuesToFiles(&m,&request_input_real_format);
     3393              loadServiceAndRun (&m, s1, request_inputs,
     3394                                 &request_input_real_format,
     3395                                 &request_output_real_format, &eres);
     3396            }
    31813397          }
    3182           if(getMapFromMaps(m,"lenv","mapError")!=NULL){
    3183             setMapInMaps(m,"lenv","message",_("Issue with geographic data"));
    3184 #ifdef USE_CALLBACK
    3185             invokeCallback(m,NULL,NULL,7,0);
    3186 #endif
    3187             eres=-1;//SERVICE_FAILED;
    3188           }else{
    3189             map* testMap=getMapFromMaps(m,"main","memory");
    3190             if(testMap==NULL || strcasecmp(testMap->value,"load")!=0)
    3191               dumpMapsValuesToFiles(&m,&request_input_real_format);
    3192             loadServiceAndRun (&m, s1, request_inputs,
    3193                                &request_input_real_format,
    3194                                &request_output_real_format, &eres);
     3398        else
     3399          {
     3400            /**
     3401             * error server don't accept the process need to output a valid
     3402             * error response here !!!
     3403             */
     3404            eres = -1;
     3405            errorException (m, _("Unable to run the child process properly"),
     3406                            "InternalError", NULL);
    31953407          }
    3196         }
    3197       else
    3198         {
    3199           /**
    3200            * error server don't accept the process need to output a valid
    3201            * error response here !!!
    3202            */
    3203           eres = -1;
    3204           errorException (m, _("Unable to run the child process properly"),
    3205                           "InternalError", NULL);
    3206         }
    3207     }
     3408      }
    32083409       
    32093410#ifdef DEBUG
    3210   fprintf (stderr, "RUN IN BACKGROUND MODE %s %d \n",__FILE__,__LINE__);
    3211   dumpMaps (request_output_real_format);
    3212   fprintf (stderr, "RUN IN BACKGROUND MODE %s %d \n",__FILE__,__LINE__);
    3213 #endif
    3214   fflush(stdout);
    3215   rewind(stdout);
    3216 
    3217   //fprintf(stderr,"%s %d %d\n",__FILE__,__LINE__,eres); 
    3218   if (eres != -1)
    3219     outputResponse (s1, request_input_real_format,
    3220                     request_output_real_format, request_inputs,
    3221                     cpid, m, eres);
    3222   fflush (stdout);
    3223  
     3411    fprintf (stderr, "RUN IN BACKGROUND MODE %s %d \n",__FILE__,__LINE__);
     3412    dumpMaps (request_output_real_format);
     3413    fprintf (stderr, "RUN IN BACKGROUND MODE %s %d \n",__FILE__,__LINE__);
     3414#endif
     3415    fflush(stdout);
     3416    rewind(stdout);
     3417
     3418    if (eres != -1)
     3419      outputResponse (s1, request_input_real_format,
     3420                      request_output_real_format, request_inputs,
     3421                      cpid, m, eres);
     3422    fflush (stdout);
     3423  }
    32243424  /**
    32253425   * Ensure that if error occurs when freeing memory, no signal will return
     
    32483448
    32493449      fclose (f0);
     3450
    32503451      fclose (f1);
    32513452
     
    32783479      zUnlink (fbkp1);
    32793480      unhandleStatus (m);
     3481#if defined(USE_JSON) || defined(USE_CALLBACK)
     3482      cleanupCallbackThreads();
     3483#endif
     3484
    32803485#ifdef RELY_ON_DB
    32813486#ifdef META_DB
    3282       cleanupCallbackThreads();
    32833487      close_sql(m,1);
    32843488#endif
     
    32873491#endif
    32883492      free(fbkpid);
    3289       free(fbkpres); 
     3493      free(fbkpres);
    32903494      free (fbkp1);
    32913495      if(cgiSid!=NULL)
    32923496        free(cgiSid);
    3293       InternetCloseHandle (&hInternet);
     3497      map* tMap=getMapFromMaps(m,"lenv","executionType");
     3498      if(tMap!=NULL && strncasecmp(tMap->value,"xml",3)==0)
     3499        InternetCloseHandle (&hInternet);
    32943500      fprintf (stderr, "RUN IN BACKGROUND MODE %s %d \n",__FILE__,__LINE__);
    32953501      fflush(stderr);
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png