Ignore:
Timestamp:
May 1, 2014, 1:28:14 AM (6 years ago)
Author:
djay
Message:

Support metapath embedded in service name. Add support for accessing ZOO-Kernel path subdirectories for full list of available services. Fix issue #98.

File:
1 edited

Legend:

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

    r467 r469  
    756756}
    757757
     758void addPrefix(maps* conf,map* level,service* serv){
     759  if(level!=NULL){
     760    char key[25];
     761    char* prefix=NULL;
     762    int clevel=atoi(level->value);
     763    int cl=0;
     764    for(cl=0;cl<clevel;cl++){
     765      sprintf(key,"sprefix_%d",cl);
     766      map* tmp2=getMapFromMaps(conf,"lenv",key);
     767      if(tmp2!=NULL){
     768        if(prefix==NULL)
     769          prefix=zStrdup(tmp2->value);
     770        else{
     771          int plen=strlen(prefix);
     772          prefix=(char*)realloc(prefix,(plen+strlen(tmp2->value)+2)*sizeof(char));
     773          memcpy(prefix+plen,tmp2->value,strlen(tmp2->value)*sizeof(char));
     774          prefix[plen+strlen(tmp2->value)]=0;
     775        }
     776      }
     777    }
     778    if(prefix!=NULL){
     779      char* tmp0=strdup(serv->name);
     780      free(serv->name);
     781      serv->name=(char*)malloc((strlen(prefix)+strlen(tmp0)+1)*sizeof(char));
     782      sprintf(serv->name,"%s%s",prefix,tmp0);
     783      free(tmp0);
     784      free(prefix);
     785      prefix=NULL;
     786    }
     787  }
     788}
     789
    758790void printGetCapabilitiesForProcess(maps* m,xmlNodePtr nc,service* serv){
    759791  xmlNsPtr ns,ns_ows,ns_xlink;
     
    776808    if(tmp1!=NULL)
    777809      xmlNewNsProp(nc1,ns,BAD_CAST "processVersion",BAD_CAST tmp1->value);
     810    map* tmp3=getMapFromMaps(m,"lenv","level");
     811    addPrefix(m,tmp3,serv);
    778812    printDescription(nc1,ns_ows,serv->name,serv->content);
    779813    tmp1=serv->metadata;
     
    816850}
    817851
    818 void printDescribeProcessForProcess(maps* m,xmlNodePtr nc,service* serv,int sc){
     852void printDescribeProcessForProcess(maps* m,xmlNodePtr nc,service* serv){
    819853  xmlNsPtr ns,ns_ows,ns_xlink,ns_xsi;
    820854  xmlNodePtr nr,n,nc1,nc2,nc3,nc4,nc5,nc6,pseudor;
     
    851885  }
    852886 
     887  tmp1=getMapFromMaps(m,"lenv","level");
     888  addPrefix(m,tmp1,serv);
    853889  printDescription(nc,ns_ows,serv->name,serv->content);
    854890
     
    18601896void printDescription(xmlNodePtr root,xmlNsPtr ns_ows,const char* identifier,map* amap){
    18611897  xmlNodePtr nc2 = xmlNewNode(ns_ows, BAD_CAST "Identifier");
     1898 
    18621899  xmlAddChild(nc2,xmlNewText(BAD_CAST identifier));
    18631900  xmlAddChild(root,nc2);
     
    19041941
    19051942void printExceptionReportResponse(maps* m,map* s){
     1943  if(getMapFromMaps(m,"lenv","hasPrinted")!=NULL)
     1944    return;
    19061945  int buffersize;
    19071946  xmlDocPtr doc;
     
    19581997  xmlCleanupParser();
    19591998  zooXmlCleanupNs();
     1999  setMapInMaps(m,"lenv","hasPrinted","true");
    19602000}
    19612001
     
    19692009  maps* tmpMap=getMaps(m,"main");
    19702010
    1971   int nsid=zooXmlAddNs(NULL,"http://www.opengis.net/ows/1.1","ows");
     2011  int nsid=zooXmlAddNs(NULL,"http://www.opengis.net/ows","ows");
    19722012  ns=usedNs[nsid];
    19732013  n = xmlNewNode(ns, BAD_CAST "ExceptionReport");
    19742014
    19752015  if(use_ns==1){
    1976     ns_ows=xmlNewNs(n,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST "ows");
     2016    ns_ows=xmlNewNs(n,BAD_CAST "http://www.opengis.net/ows/1.1.0",BAD_CAST "ows");
    19772017    int xsiId=zooXmlAddNs(n,"http://www.w3.org/2001/XMLSchema-instance","xsi");
    19782018    ns_xsi=usedNs[xsiId];
     2019    ns_xsi=xmlNewNs(n,BAD_CAST "http://www.w3.org/2001/XMLSchema-instance",BAD_CAST "xsi");
     2020    xmlNewNsProp(n,ns_xsi,BAD_CAST "schemaLocation",BAD_CAST "http://www.opengis.net/ows/1.1 http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd");
    19792021    int xlinkId=zooXmlAddNs(n,"http://www.w3.org/1999/xlink","xlink");
    19802022    ns_xlink=usedNs[xlinkId];
    1981     xmlNewNsProp(n,ns_xsi,BAD_CAST "schemaLocation",BAD_CAST "http://www.opengis.net/ows/1.1 http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd");
    19822023  }
    19832024  addLangAttr(n,m);
     
    28482889  return -1;
    28492890}
     2891
     2892#ifdef USE_MS
     2893char *readVSIFile(maps* conf,const char* dataSource){
     2894    VSILFILE * fichier=VSIFOpenL(dataSource,"rb");
     2895    VSIStatBufL file_status;
     2896    VSIStatL(dataSource, &file_status);
     2897    if(fichier==NULL){
     2898      char tmp[1024];
     2899      sprintf(tmp,"Failed to open file %s for reading purpose. File seems empty %d.",
     2900              dataSource,file_status.st_size);
     2901      setMapInMaps(conf,"lenv","message",tmp);
     2902      return NULL;
     2903    }
     2904    char *res1=(char *)malloc(file_status.st_size*sizeof(char));
     2905    VSIFReadL(res1,1,(file_status.st_size)*sizeof(char),fichier);
     2906    VSIFCloseL(fichier);
     2907    VSIUnlink(dataSource);
     2908    return res1;
     2909}
     2910#endif
     2911
     2912void parseIdentifier(maps* conf,char* conf_dir,char *identifier,char* buffer){
     2913  char *saveptr1;
     2914  char *tmps1=strtok_r(identifier,".",&saveptr1);
     2915  int level=0;
     2916  char key[25];
     2917  char levels[18];
     2918  while(tmps1!=NULL){
     2919    char *test=zStrdup(tmps1);
     2920    char* tmps2=(char*)malloc((strlen(test)+2)*sizeof(char));
     2921    sprintf(key,"sprefix_%d",level);
     2922    sprintf(tmps2,"%s.",test);
     2923    sprintf(levels,"%d",level);
     2924    setMapInMaps(conf,"lenv","level",levels);
     2925    setMapInMaps(conf,"lenv",key,tmps2);
     2926    free(tmps2);
     2927    level++;
     2928    tmps1=strtok_r(NULL,".",&saveptr1);
     2929  }
     2930  int i=0;
     2931  sprintf(buffer,"%s",conf_dir);
     2932  for(i=0;i<level;i++){
     2933    char *tmp0=zStrdup(buffer);
     2934    sprintf(key,"sprefix_%d",i);
     2935    map* tmp00=getMapFromMaps(conf,"lenv",key);
     2936    sprintf(buffer,"%s/%s",tmp0,tmp00->value);
     2937    free(tmp0);
     2938    buffer[strlen(buffer)-1]=0;
     2939    if(i+1<level){
     2940      map* tmpMap=getMapFromMaps(conf,"lenv","metapath");
     2941      if(tmpMap==NULL || strlen(tmpMap->value)==0){
     2942        char *tmp01=zStrdup(tmp00->value);
     2943        tmp01[strlen(tmp01)-1]=0;
     2944        setMapInMaps(conf,"lenv","metapath",tmp01);
     2945        free(tmp01);
     2946      }
     2947      else{
     2948        char *value=(char*)malloc((strlen(tmp00->value)+strlen(tmpMap->value)+2)*sizeof(char));
     2949        sprintf(value,"%s/%s",tmpMap->value,tmp00->value);
     2950        value[strlen(value)-1]=0;
     2951        setMapInMaps(conf,"lenv","metapath",value);
     2952        free(value);
     2953      }
     2954    }else{
     2955      char *tmp0=zStrdup(tmp00->value);
     2956      tmp0[strlen(tmp0)-1]=0;
     2957      setMapInMaps(conf,"lenv","Identifier",tmp0);
     2958      free(tmp0);
     2959    }
     2960  }
     2961  char *tmp0=zStrdup(buffer);
     2962  sprintf(buffer,"%s.zcfg",tmp0);
     2963  free(tmp0);
     2964}
     2965
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