A service now supports settings (set) which will be inherited by targets
authorDennis Schafroth <dennis@indexdata.com>
Thu, 19 Apr 2012 10:29:35 +0000 (12:29 +0200)
committerDennis Schafroth <dennis@indexdata.com>
Thu, 19 Apr 2012 10:30:22 +0000 (12:30 +0200)
Attribute limitmap on metadata will also be unfolded into a
pz:limitmap:<name> setting. These will be used as
"default" settings, if nothing is specified for a target.

This should make it possible to fix bug 5448 by some configuration.

src/pazpar2_config.c

index 2e5f984..ab4382b 100644 (file)
@@ -112,13 +112,14 @@ static void conf_sortkey_assign(NMEM nmem,
     sortkey->type = type;
 }
 
-static struct conf_service *service_init(struct conf_server *server,
+struct conf_service *service_init(struct conf_server *server,
                                          int num_metadata, int num_sortkeys,
                                          const char *service_id)
 {
     struct conf_service * service = 0;
     NMEM nmem = nmem_create();
 
+
     service = nmem_malloc(nmem, sizeof(struct conf_service));
     service->mutex = 0;
     service->ref_count = 1;
@@ -134,7 +135,19 @@ static struct conf_service *service_init(struct conf_server *server,
     service->charsets = 0;
 
     service->id = service_id ? nmem_strdup(nmem, service_id) : 0;
+    // Setup a dictionary from server.
+    service->dictionary = 0;
+
+    service->settings = nmem_malloc(nmem, sizeof(struct settings));
+    service->settings->num_settings = PZ_MAX_EOF;
+    service->settings->settings = nmem_malloc(nmem, sizeof(struct setting*) * service->settings->num_settings);
+    memset(service->settings->settings, 0, sizeof(struct setting*) * service->settings->num_settings);
+    //  inherit_server_settings_values(service);
+
+    service->next = 0;
+
     service->num_metadata = num_metadata;
+
     service->metadata = 0;
     if (service->num_metadata)
         service->metadata 
@@ -146,7 +159,8 @@ static struct conf_service *service_init(struct conf_server *server,
         service->sortkeys 
             = nmem_malloc(nmem, 
                           sizeof(struct conf_sortkey) * service->num_sortkeys);
-    service->dictionary = 0;
+
+
     return service; 
 }
 
@@ -310,12 +324,12 @@ static int parse_metadata(struct conf_service *service, xmlNode *n,
         else if (!xmlStrcmp(attr->name, BAD_CAST "mergekey") &&
                  attr->children && attr->children->type == XML_TEXT_NODE)
             xml_mergekey = attr->children->content;
-        else if (!xmlStrcmp(attr->name, BAD_CAST "limitmap") &&
-                 attr->children && attr->children->type == XML_TEXT_NODE)
-            xml_limitmap = attr->children->content;
         else if (!xmlStrcmp(attr->name, BAD_CAST "facetrule") &&
                  attr->children && attr->children->type == XML_TEXT_NODE)
             xml_icu_chain = attr->children->content;
+        else if (!xmlStrcmp(attr->name, BAD_CAST "limitmap") &&
+                 attr->children && attr->children->type == XML_TEXT_NODE)
+            xml_limitmap = attr->children->content;
         else
         {
             yaz_log(YLOG_FATAL, "Unknown metadata attribute '%s'", attr->name);
@@ -565,6 +579,15 @@ static struct conf_service *service_create_static(struct conf_server *server,
             if (service_xslt_config(service, n))
                 return 0;
         }
+        else if (!strcmp((const char *) n->name, (const char *) "set"))
+        {
+            xmlChar *name= xmlGetProp(n, (xmlChar *) "name");
+            xmlChar *value = xmlGetProp(n, (xmlChar *) "value");
+            if (service->dictionary && name && value) {
+                yaz_log(YLOG_DEBUG, "service set: %s=%s (Not implemented)", (char *) name, (char *) value);
+                //service_aply_setting(service, name, value);
+            }
+        }
         else
         {
             yaz_log(YLOG_FATAL, "Bad element: %s", n->name);
@@ -618,8 +641,7 @@ static void inherit_server_settings(struct conf_service *s)
         }
         else
         {
-            yaz_log(YLOG_WARN, "service '%s' has no settings",
-                    s->id ? s->id : "unnamed");
+            yaz_log(YLOG_WARN, "server '%s' has no settings", s->id ? s->id : "unnamed");
             init_settings(s);
         }
     }
@@ -643,8 +665,7 @@ static void inherit_server_settings(struct conf_service *s)
 struct conf_service *service_create(struct conf_server *server,
                                     xmlNode *node)
 {
-    struct conf_service *service = service_create_static(server,
-                                                         node, 0);
+    struct conf_service *service = service_create_static(server, node, 0);
     if (service)
     {
         inherit_server_settings(service);