]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/http_getter/http_getter.pl.in
Experimental commit that implements the getalluris method, that gives back in
[helm.git] / helm / http_getter / http_getter.pl.in
index 48371bd272c3108986b0fc7cb827b1521a4d5a97..c9cac35f2904741994c5b3cc67bdbb34738c7324 100755 (executable)
@@ -65,6 +65,8 @@ my $rdf_indexname = $ENV{'HTTP_GETTER_RDF_INDEXNAME'} ||
   "rdf_index.txt";
 my $xslt_indexname = $ENV{'HTTP_GETTER_XSLT_INDEXNAME'} ||
   "xslt_index.txt";
+$servers_file = $ENV{'HTTP_GETTER_SERVERS_FILE'} || $servers_file;
+$uris_dbm = $ENV{'HTTP_GETTER_URIS_DBM'} || $uris_dbm;
   
 # </move_to_conf_file>
 
@@ -106,15 +108,18 @@ print "\n";
 print "HTTP Getter $VERSION\n"; # print hello information
 print "Please contact me at: <URL:", $myownurl."/", ">\n";
 print "\n";
+print "servers_file: $servers_file\n";
 print "helm_dir: $helm_dir\n";
 print "helm_rdf_dir: $helm_rdf_dir\n";
 print "style_dir: $style_dir\n";
 print "dtd_dir: $dtd_dir\n";
 print "urls_of_uris db: $uris_dbm\n";
 print "rdf db: $rdf_dbm\n";
+print "xslt db: $xslt_dbm\n";
 print "cache mode: $cachemode\n";
 print "indexname: $indexname\n";
 print "rdf_indexname: $rdf_indexname\n";
+print "xslt_indexname: $xslt_indexname\n";
 print "\n";
 
 $SIG{CHLD} = "IGNORE"; # do not accumulate defunct processes
@@ -258,8 +263,9 @@ while (my $c = $d->accept) {
 
         } elsif ($http_method eq 'GET' and $http_path eq "/getxslt") {
 
+          $url = $xslt_map{$inputuri};
           print "Downloading XSLT ...\n";
-          helm_wget($tmp_dir, $inputuri);
+          helm_wget($tmp_dir, $url);
           print "XSLT downloaded!\n";
           $inputuri =~ s/.*\///;
           my $filename = $tmp_dir . "/" . $inputuri;
@@ -269,7 +275,7 @@ while (my $c = $d->accept) {
           while(<FD>) {
             s/xsl:import\s+href="/xsl:import href="$myownurl\/getxslt?uri=/g;
             s/xsl:include\s+href="/xsl:include href="$myownurl\/getxslt?uri=/g;
-            $cont =. $_;
+            $cont .= $_;
           }
           close(FD);
           answer($c, $cont, "text/xml", "");
@@ -307,7 +313,13 @@ while (my $c = $d->accept) {
            print " done\n";
            html_nice_answer($c,"Update done");
 
-                                 # "/ls" does not work with rdf uris
+                                 # "/getalluris" does not work with rdf uris
+        } elsif ($http_method eq 'GET' and $http_path eq "/getalluris") {
+            # send back all the keys in xml
+            print "BASEURI $baseuri, FORMAT $outype\n";
+            $cont = getalluris();
+            answer($c,$cont,"text/xml","");
+
         } elsif ($http_method eq 'GET' and $http_path eq "/ls") {
             # send back keys that begin with a given uri
            my ($uritype,$uripattern,$uriprefix);
@@ -437,6 +449,25 @@ sub resolve { # resolve an uri in a url, work both with standard cic: or theory:
  }
 }
 
+sub getalluris { # get all the keys whose prefix is cic
+ my $content = "";
+ my ($uri);
+ my $debug=1; # for debug
+
+  $content .= '<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n";
+  $content .= "<!DOCTYPE alluris SYSTEM ";
+  $content .= "\"$myownurl/getdtd?uri=alluris.dtd\">" . "\n\n";
+  $content .= "<alluris>\n";
+  foreach $uri (sort (keys(%xml_map))) { # select matching uris
+   if ($uri =~ /^cic:/ && not $uri =~ /.types$/) {
+    print "GETALLURI: $uri\n" if defined($debug);
+    $content .= "\t<uri value=\"$uri\"/>\n";
+   }
+  }
+  $content .= "</alluris>\n";
+ return $content;
+}
+
 sub finduris { # find uris for cic and theory trees generation
  my ($uritype,$uripattern,$format) = @_;
  my $content = "";
@@ -861,7 +892,7 @@ sub update_dbs {
   close XSLT_INDEX;
 
                   # remove temp files
-  foreach my $file in ($idxfile, $rdf_idxfile, $xslt_idxfile) {
+  foreach my $file ($idxfile, $rdf_idxfile, $xslt_idxfile) {
     print "cannot unlink temporary file: $file\n" if (unlink $file) != 1;
   }