Index: main/trunk/greenstone2/perllib/lucenebuilder.pm
===================================================================
--- main/trunk/greenstone2/perllib/lucenebuilder.pm	(revision 27328)
+++ main/trunk/greenstone2/perllib/lucenebuilder.pm	(revision 27329)
@@ -47,4 +47,5 @@
 no strict 'refs';
 use util;
+use FileUtils;
 
 sub BEGIN {
@@ -64,5 +65,5 @@
     # If ENABLE_LUCENE was turned off during GS compilation, then we won't be able to
     # continue. Check for existence of LuceneWrapper to see if Lucene was disabled.
-    my $lucene = &util::filename_cat($ENV{'GSDLHOME'},"bin","java","LuceneWrapper.jar");
+    my $lucene = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'},"bin","java","LuceneWrapper3.jar");
     if (! -f $lucene) {
 	die "***** ERROR: $lucene does not exist\n";	  
@@ -74,5 +75,5 @@
 
     # So where is lucene_passes.pl anyway?
-    my $lucene_passes_script = &util::filename_cat($scriptdir, "lucene_passes.pl");
+    my $lucene_passes_script = &FileUtils::filenameConcatenate($scriptdir, "lucene_passes.pl");
 
     # So tack perl on the beginning to ensure execution
@@ -109,5 +110,6 @@
     if (defined $buildcfg->{'indexfields'}) {
 	foreach $field (@{$buildcfg->{'indexfields'}}) {
-	    $self->{'buildproc'}->{'indexfields'}->{$field} = 1;
+	    # extraindexfields is only supposed to have extra ones in it, not those already specified in indexes. And this list has all indexes in it. But we do a check before including things from extraindexfields whether it was specified in indexes, so it all ok.
+	    $self->{'buildproc'}->{'extraindexfields'}->{$field} = 1;
 	}
     }
@@ -116,6 +118,7 @@
 	foreach $field (@{$buildcfg->{'indexfieldmap'}}) {
 	    my ($f, $v) = $field =~ /^(.*)\-\>(.*)$/;
-	    $self->{'buildproc'}->{'indexfieldmap'}->{$f} = $v;
-	    $self->{'buildproc'}->{'indexfieldmap'}->{$v} = 1;
+	    $self->{'buildproc'}->{'fieldnamemap'}->{$f} = $v;
+	    $self->{'buildproc'}->{'fieldnamemap'}->{$v} = 1;
+	    $self->{'buildproc'}->{'allindexfields'}->{$f} = 1;
 	}
     }	    
@@ -151,7 +154,7 @@
 
     # the text directory
-    my $text_dir = &util::filename_cat($self->{'build_dir'}, "text");
-    my $build_dir = &util::filename_cat($self->{'build_dir'},"");
-    &util::mk_all_dir ($text_dir);
+    my $text_dir = &FileUtils::filenameConcatenate($self->{'build_dir'}, "text");
+    my $build_dir = &FileUtils::filenameConcatenate($self->{'build_dir'},"");
+    &FileUtils::makeAllDirectories ($text_dir);
 
     my $osextra = "";
@@ -209,5 +212,4 @@
     $self->{'buildproc'}->set_index ($textindex);
     $self->{'buildproc'}->set_indexing_text (0);
-    #$self->{'buildproc'}->set_indexfieldmap ($self->{'indexfieldmap'});
     $self->{'buildproc'}->set_levels ($levels);
     $self->{'buildproc'}->set_db_level ($db_level);
@@ -306,5 +308,5 @@
     # get the full index directory path and make sure it exists
     my $indexdir = $self->{'index_mapping'}->{$index};
-    &util::mk_all_dir (&util::filename_cat($build_dir, $indexdir));
+    &FileUtils::makeAllDirectories (&FileUtils::filenameConcatenate($build_dir, $indexdir));
 
     # get any os specific stuff
@@ -433,5 +435,5 @@
 
     # Get info database file path
-    my $text_directory_path = &util::filename_cat($self->{'build_dir'}, "text");
+    my $text_directory_path = &FileUtils::filenameConcatenate($self->{'build_dir'}, "text");
     my $infodb_file_path = &dbutil::get_infodb_file_path($self->{'infodbtype'}, $self->{'collection'}, $text_directory_path);
 
@@ -460,6 +462,6 @@
     #    don't expect to pipe anything to the database so we can do away with the
     #    complex output handle.
-    my $assocdir = &util::filename_cat($self->{'build_dir'}, "assoc");
-    &util::mk_all_dir ($assocdir);
+    my $assocdir = &FileUtils::filenameConcatenate($self->{'build_dir'}, "assoc");
+    &FileUtils::makeAllDirectories ($assocdir);
     $self->{'buildproc'}->set_mode ('incinfodb'); # Very Important
     $self->{'buildproc'}->set_assocdir ($assocdir);
Index: main/trunk/greenstone2/perllib/lucenebuildproc.pm
===================================================================
--- main/trunk/greenstone2/perllib/lucenebuildproc.pm	(revision 27328)
+++ main/trunk/greenstone2/perllib/lucenebuildproc.pm	(revision 27329)
@@ -96,23 +96,8 @@
     my $lsec_level = $levels->{'section'};
 
-    # gs2_id should be depricated #####
-    my $gs2_id = "";
-    if ($ldoc_level)
-    {
-	if ($self->{'db_level'} eq 'document')
-	{
-	    $gs2_id = $self->{'num_docs'};
-	}
-        else
-	{
-	    # default is section level
-	    $gs2_id = $self->{'num_sections'} + 1;
-	}
-    }
     my $gs2_docOID = $doc_obj->get_OID();
     my $documenttag = undef;
     my $documentendtag = undef;
 
-    #$documenttag = "<$doc_tag_name xmlns:gs2=\"http://www.greenstone.org/gs2\" file=\"$file\" gs2:id=\"$gs2_id\" gs2:docOID=\"$gs2_docOID\" gs2:mode=\"$edit_mode\">\n";
     $documenttag = "<$doc_tag_name xmlns:gs2=\"http://www.greenstone.org/gs2\" file=\"$file\"  gs2:docOID=\"$gs2_docOID\" gs2:mode=\"$edit_mode\">\n";
     $documentendtag = "\n</$doc_tag_name>\n";
@@ -146,5 +131,4 @@
 	if (($indexed_doc == 0) || ($indexed_section ne "indexed_section" && $indexed_section ne "indexed_doc")) {
 	    if ($sec_tag_name ne "") {
-		#$text .= "\n<$sec_tag_name gs2:id=\"$sec_gs2_id\" gs2:docOID=\"$sec_gs2_docOID\" gs2:mode=\"ignore\">\n";
 		$text .= "\n<$sec_tag_name  gs2:docOID=\"$sec_gs2_docOID\" gs2:mode=\"ignore\">\n";
 		$text .= "\n</$sec_tag_name>\n" 
@@ -156,5 +140,4 @@
 	if ($sec_tag_name ne "")
 	{
-	    #$text .= "\n<$sec_tag_name gs2:id=\"$sec_gs2_id\" gs2:docOID=\"$sec_gs2_docOID\" gs2:mode=\"$edit_mode\">\n";
 	    $text .= "\n<$sec_tag_name  gs2:docOID=\"$sec_gs2_docOID\" gs2:mode=\"$edit_mode\">\n";
 	}
@@ -200,12 +183,11 @@
 	    my $shortname="";
 	    my $new_field = 0; # have we found a new field name?
-	    if (defined $self->{'indexfieldmap'}->{$real_field}) {
-		$shortname = $self->{'indexfieldmap'}->{$real_field};
-	    }
-	    else {
+	    if (defined $self->{'fieldnamemap'}->{$real_field}) {
+		$shortname = $self->{'fieldnamemap'}->{$real_field};
+	    } else {
 		$shortname = $self->create_shortname($real_field);
-		$new_field = 1;
-	    }
-
+		$self->{'fieldnamemap'}->{$real_field} = $shortname;
+		$self->{'fieldnamemap'}->{$shortname} = 1;
+	    }
 	    my @metadata_list = (); # put any metadata values in here
 	    my $section_text = ""; # put the text in here
@@ -260,4 +242,5 @@
 		    # add the tag
 		    $new_text = "<$shortname index=\"1\">$new_text</$shortname>";
+		    $self->{'allindexfields'}->{$real_field} = 1;
 		}
 		# filter the text
@@ -271,14 +254,5 @@
 		    # delete
 		    $self->{'num_processed_bytes'} -= length ($new_text);
-		}
-		
-
-		if ($self->{'indexing_text'} && $new_field) {
-		    # we need to add to the list in indexfields
-		    
-		    $self->{'indexfieldmap'}->{$real_field} = $shortname;
-		    $self->{'indexfieldmap'}->{$shortname} = 1;
-		}
-		
+		}		
 	    }
 	    
@@ -302,12 +276,13 @@
 		&ghtml::htmlsafe($mvalue);
 		
-		if (defined $self->{'indexfieldmap'}->{$mfield}) {
-		    $shortname = $self->{'indexfieldmap'}->{$mfield};
+		if (defined $self->{'fieldnamemap'}->{$mfield}) {
+		    $shortname = $self->{'fieldnamemap'}->{$mfield};
 		}
 		else {
 		    $shortname = $self->create_shortname($mfield);
-		    $self->{'indexfieldmap'}->{$mfield} = $shortname;
-		    $self->{'indexfieldmap'}->{$shortname} = 1;
-		}	   
+		    $self->{'fieldnamemap'}->{$mfield} = $shortname;
+		    $self->{'fieldnamemap'}->{$shortname} = 1;
+		}
+		$self->{'allindexfields'}->{$mfield} = 1;
 		$new_text .= "<$shortname index=\"1\">$mvalue</$shortname>\n";
 		if ($allfields_index) {
@@ -315,6 +290,6 @@
 		}
 
-		if (!defined $self->{'indexfields'}->{$mfield}) {
-		    $self->{'indexfields'}->{$mfield} = 1;
+		if (!defined $self->{'extraindexfields'}->{$mfield}) {
+		    $self->{'extraindexfields'}->{$mfield} = 1;
 		}				    
 	    
@@ -334,7 +309,4 @@
 
 	if ($allfields_index) {
-	    # add the index name mapping
-	    $self->{'indexfieldmap'}->{"allfields"} = "ZZ";
-	    $self->{'indexfieldmap'}->{"ZZ"} = 1;
 	    
 	    my $new_text = "<ZZ index=\"1\">$allfields_text</ZZ>\n";
