Ignore:
Timestamp:
Jun 19, 2015, 3:58:00 PM (9 years ago)
Author:
djay
Message:

Move createRegistry function to server_internal. Add the utils/registry service.

File:
1 edited

Legend:

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

    r657 r676  
    966966          sprintf(fileName,"%s/%s",r_inputs->value,dp->d_name);
    967967          if(unlink(fileName)!=0){
    968             errorException (conf, _("The job cannot be removed, a file cannot be removed"),
     968            errorException (conf,
     969                            _("The job cannot be removed, a file cannot be removed"),
    969970                            "NoApplicableCode", NULL);
    970971            return;
     
    983984  return;
    984985}
     986
     987extern int getServiceFromFile (maps *, const char *, service **);
     988
     989/**
     990 * Parse the service file using getServiceFromFile or use getServiceFromYAML
     991 * if YAML support was activated.
     992 *
     993 * @param conf the conf maps containing the main.cfg settings
     994 * @param file the file name to parse
     995 * @param service the service to update witht the file content
     996 * @param name the service name
     997 * @return true if the file can be parsed or false
     998 * @see getServiceFromFile, getServiceFromYAML
     999 */
     1000int readServiceFile (maps * conf, char *file, service ** service, char *name){
     1001  int t = getServiceFromFile (conf, file, service);
     1002#ifdef YAML
     1003  if (t < 0){
     1004    t = getServiceFromYAML (conf, file, service, name);
     1005  }
     1006#endif
     1007  return t;
     1008}
     1009
     1010/**
     1011 * Create the profile registry.
     1012 *
     1013 * The profile registry is optional (created only if the registry key is
     1014 * available in the [main] section of the main.cfg file) and can be used to
     1015 * store the profiles hierarchy. The registry is a directory which should
     1016 * contain the following sub-directories:
     1017 *  * concept: direcotry containing .html files describing concept
     1018 *  * generic: directory containing .zcfg files for wps:GenericProcess
     1019 *  * implementation: directory containing .zcfg files for wps:Process
     1020 *
     1021 * @param m the conf maps containing the main.cfg settings
     1022 * @param r the registry to update
     1023 * @param reg_dir the resgitry
     1024 * @return 0 if the resgitry is null or was correctly updated, -1 on failure
     1025 */
     1026int createRegistry (maps* m,registry ** r, char *reg_dir)
     1027{
     1028  char registryKeys[3][15]={
     1029    "concept",
     1030    "generic",
     1031    "implementation"
     1032  };
     1033  int scount = 0,i=0;
     1034  if (reg_dir == NULL)
     1035    return 0;
     1036  for(i=0;i<3;i++){
     1037    char * tmpName =
     1038      (char *) malloc ((strlen (reg_dir) + strlen (registryKeys[i]) + 2) *
     1039                       sizeof (char));
     1040    sprintf (tmpName, "%s/%s", reg_dir, registryKeys[i]);
     1041   
     1042    DIR *dirp1 = opendir (tmpName);
     1043    struct dirent *dp1;
     1044    while ((dp1 = readdir (dirp1)) != NULL){
     1045      char* extn = strstr(dp1->d_name, ".zcfg");
     1046      if(dp1->d_name[0] != '.' && extn != NULL && strlen(extn) == 5)
     1047        {
     1048          int t;
     1049          char *tmps1=
     1050            (char *) malloc ((strlen (tmpName) + strlen (dp1->d_name) + 2) *
     1051                             sizeof (char));
     1052          sprintf (tmps1, "%s/%s", tmpName, dp1->d_name);
     1053          char *tmpsn = zStrdup (dp1->d_name);
     1054          tmpsn[strlen (tmpsn) - 5] = 0;
     1055          service* s1 = (service *) malloc (SERVICE_SIZE);
     1056          if (s1 == NULL)
     1057            {
     1058              setMapInMaps(m,"lenv","message",_("Unable to allocate memory."));
     1059              setMapInMaps(m,"lenv","type","InternalError");
     1060              return -2;
     1061            }
     1062          t = readServiceFile (m, tmps1, &s1, tmpsn);
     1063          free (tmpsn);
     1064          if (t < 0)
     1065            {
     1066              map *tmp00 = getMapFromMaps (m, "lenv", "message");
     1067              char tmp01[1024];
     1068              if (tmp00 != NULL)
     1069                sprintf (tmp01, _("Unable to parse the ZCFG file: %s (%s)"),
     1070                         dp1->d_name, tmp00->value);
     1071              else
     1072                sprintf (tmp01, _("Unable to parse the ZCFG file: %s."),
     1073                         dp1->d_name);
     1074              setMapInMaps(m,"lenv","message",tmp01);
     1075              setMapInMaps(m,"lenv","type","InternalError");
     1076              return -1;
     1077            }
     1078          if(strncasecmp(registryKeys[i],"implementation",14)==0){
     1079            inheritance(*r,&s1);
     1080          }
     1081          addServiceToRegistry(r,registryKeys[i],s1);
     1082          freeService (&s1);
     1083          free (s1);
     1084          scount++;
     1085        }
     1086    }
     1087    (void) closedir (dirp1);
     1088  }
     1089  return 0;
     1090}
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