Ignore:
Timestamp:
Jan 10, 2017, 5:21:45 PM (7 years ago)
Author:
djay
Message:

Return an ExceptionReport? in case any inpts failed to be downloaded.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-project/zoo-kernel/caching.c

    r790 r797  
    154154 * @param index the input index
    155155 * @param hInternet the internet connection
    156  * @return 0 in case of success, 4 in case of failure
    157  */
    158 int readCurrentInput(maps** m,maps** in,int* index,HINTERNET* hInternet){
     156 * @param error the error map pointer
     157 * @return 0 in case of success, -1 in case of failure
     158 */
     159int readCurrentInput(maps** m,maps** in,int* index,HINTERNET* hInternet,map** error){
    159160  map* tmp1;
    160161  char sindex[5];
     
    207208     
    208209      if(getMap(content->content,icname)==NULL){
    209        
    210210        fcontent=(char*)malloc((hInternet->ihandle[*index].nDataLen+1)*sizeof(char));
    211211        if(fcontent == NULL){
    212           return errorException(*m, _("Unable to allocate memory"), "InternalError",NULL);
     212          errorException(*m, _("Unable to allocate memory"), "InternalError",NULL);
     213          return -1;
    213214        }
    214215        size_t dwRead;
     
    231232        }
    232233        memcpy(tmpMap->value,fcontent,(fsize+1)*sizeof(char));
     234        if(hInternet->ihandle[*index].code!=200){
     235          char *error_rep_str=_("Unable to download the file for the input <%s>, response code was : %d.");
     236          char *error_msg=(char*)malloc((strlen(error_rep_str)+strlen(content->name)+4)*sizeof(char));
     237          sprintf(error_msg,error_rep_str,content->name,hInternet->ihandle[*index].code);
     238          if(*error==NULL){
     239            *error=createMap("text",error_msg);
     240            addToMap(*error,"locator",content->name);
     241            addToMap(*error,"code","InvalidParameterValue");
     242          }else{
     243            int nb=1;
     244            map* tmpMap=getMap(*error,"length");
     245            if(tmpMap!=NULL)
     246              nb=atoi(tmpMap->value);
     247            setMapArray(*error,"text",nb,error_msg);
     248            setMapArray(*error,"locator",nb,content->name);
     249            setMapArray(*error,"code",nb,"InvalidParameterValue");
     250          }
     251          return -1;
     252        }
    233253       
    234254        char ltmp1[256];
     
    266286 *  per default based on the zcfg file)
    267287 * @param hInternet the HINTERNET pointer
    268  * @return 0 on success
    269  */
    270 int runHttpRequests(maps** m,maps** inputs,HINTERNET* hInternet){
     288 * @param error the error map pointer
     289 * @return 0 on success, -1 on failure
     290 */
     291int runHttpRequests(maps** m,maps** inputs,HINTERNET* hInternet,map** error){
     292  int hasAFailure=0;
    271293  if(hInternet!=NULL && hInternet->nb>0){
    272294    processDownloads(hInternet);
     
    277299        maps* cursor=content->child;
    278300        while(cursor!=NULL){
    279           readCurrentInput(m,&cursor,&index,hInternet);
     301          int red=readCurrentInput(m,&cursor,&index,hInternet,error);
     302          if(red<0)
     303            hasAFailure=red;
    280304          cursor=cursor->next;
    281305        }
    282306      }
    283       else
    284         readCurrentInput(m,&content,&index,hInternet);
     307      else{
     308        int red=readCurrentInput(m,&content,&index,hInternet,error);
     309        if(red<0)
     310          hasAFailure=red;
     311      }
    285312      content=content->next;
    286     } 
    287   }
    288   return 0;
     313    }
     314  }
     315  return hasAFailure;
    289316}
    290317
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