Index: /main/trunk/greenstone2/perllib/oaiinfo.pm
===================================================================
--- /main/trunk/greenstone2/perllib/oaiinfo.pm	(revision 31191)
+++ /main/trunk/greenstone2/perllib/oaiinfo.pm	(revision 31192)
@@ -4,8 +4,4 @@
 use constant INFO_STATUS_INDEX  => 0;
 use constant INFO_TIMESTAMP_INDEX => 1;
-
-use constant NO_PD_STEP => 0; # no needing to mark db with "provisionally deleted", no PD pass
-use constant DO_PD_STEP => 1; # PD pass required (pass to mark db "PD" and then later undo it).
-# or SPECIAL_PROCESSING_REQUIRED => 1???
 
 use strict;
@@ -71,11 +67,8 @@
     }
 
-    if($removeold) {
-	$self->{'removeold_no_manifest'} = 1;
-	$self->{'do_pd_step'} = DO_PD_STEP; # step where all E will be marked as PD
-    } else {
-	$self->{'removeold_no_manifest'} = 0;
-	$self->{'do_pd_step'} = NO_PD_STEP;
-    }
+    my $do_pd_step = ($removeold) ? 1 : 0;
+       # if $removeold, then proper full rebuild, will carry out step where all E will be marked as PD
+       # else some kind of incremental build, won't do the extra PD pass 
+       # which is the step marking existing OIDs (E) as PD (provisionally deleted)	
     
     my $oaidb_live_filepath = $self->{'oaidb_live_filepath'};
@@ -85,7 +78,4 @@
     my $livedb_exists = &FileUtils::fileExists($oaidb_live_filepath);
     my $tmpdb_exists = &FileUtils::fileExists($oaidb_tmp_filepath);    
-
-#    print STDERR "############ LIVE DB: $self->{'oaidb_live_filepath'}\n";
-#    print STDERR "############ TMP DB: $self->{'oaidb_tmp_filepath'}\n";
 
     my $initdb = 0;
@@ -143,5 +133,5 @@
 
     if($work_with_empty_tmpdb) { # we'll use an empty tmpdb
-	
+
 	# If importing the collection for the very first time, neither db exists, 
 	# so create an empty tmpdb.
@@ -161,5 +151,5 @@
 	# "keepold" (keepold means "only add, don't reprocess existing"). So
 	# no need to do the special passes dealing with "provisional deletes".
-	$self->{'do_pd_step'} = NO_PD_STEP;
+	$do_pd_step = 0;
 	
     } elsif ($make_contents_of_tmpdb_that_of_livedb) {
@@ -195,19 +185,5 @@
 #    print STDERR "@@@@@ oaidb: $self->{'oaidb_file_path'}\n";
     
-    return $self->{'do_pd_step'};
-}
-
-sub set_proc_mode {
-    my $self = shift (@_);
-    my ($mode) = @_;
-    
-    $self->{'do_pd_step'} = $mode;
-}
-
-# returns 1 if doing PD step (marking entries as provisionally deleted)
-# returns 0 if not doing PD step, which happens when we're purely incremental or building first time.
-sub get_proc_mode {
-    my $self = shift (@_);
-    return $self->{'do_pd_step'};
+    return $do_pd_step;
 }
 
@@ -221,11 +197,9 @@
     my ($removeold, $have_manifest) = @_;
     
-
     my $do_pd_step = $self->init_tmpdb($removeold, $have_manifest);
-       # 1 if the step to mark oaidb entries as PD is required
-       # if we're doing full rebuilding and it's NOT the first time creating the oai_inf db, 
-       # then the tasks to do with PD (provisionally deleted) OAI OIDs should be carried out
-
-    
+      # returns 1 if the step to mark oaidb entries as PD is required
+      # if we're doing full rebuilding and it's NOT the first time creating the oai_inf db, 
+      # then the tasks to do with PD (provisionally deleted) OAI OIDs should be carried out
+
     $self->load_info();
     $self->print_info(); # DEBUGGING
@@ -320,32 +294,4 @@
 }
 
-############################### FOR FULL AND INCR BUILDING ##########################
-# add or reindex if incremental (updating timestamp to current), 
-# add or (re-)mark PDs as status=E for existing if full build, keeping timestamp.
-# This subroutine will end up adding if firstbuild (since then the OID won't already exist)
-sub Xprocess_new_or_existing { 
-    my $self = shift (@_);
-    my ($OID) = @_;	
-    
-    my $OID_info = $self->{'info'}->{$OID};
-    if (defined $OID_info) { 
-	
-	if ($self->{'do_pd_step'} == NO_PD_STEP) {  # update modification time for reindexed doc
-	    $OID_info->[INFO_TIMESTAMP_INDEX] = $self->get_current_time();
-	}	
-	else { # mode is DO_PD_STEP
-	    $OID_info->[INFO_STATUS_INDEX] = "E"; # will flip any PD status of existing documents back to E, 
-	    # so need to keep existing timestamps. 
-	    # Can't be called on deleted docs, so status was never D
-	    # $self->set_status_info($OID, "E"); # will only set it if OID exists
-	    
-	    
-	}
-    } else { # if OID is not present, then it's new and now added as existing from current time on
-	$self->set_info($OID, "E", $self->get_current_time());
-    }	
-    
-}
-
 ##################### SPECIFIC TO PD-STEP ####################
 
@@ -360,7 +306,8 @@
 
     foreach my $OID (keys $self->{'info'}) {
-	my $curr_status = $self->get_status_info($OID);
-	if(defined $curr_status && $curr_status eq "E") {
-	    $self->set_status_info($OID, "PD");
+	my $OID_info = $self->{'info'}->{$OID};
+	my $curr_status = $OID_info->[INFO_STATUS_INDEX];
+	if($curr_status eq "E") {	    
+	    $OID_info->[INFO_STATUS_INDEX] = "PD";
 	}
     }
@@ -375,6 +322,7 @@
 
     foreach my $OID (keys $self->{'info'}) {
-	my $curr_status = $self->get_status_info($OID);
-	if(defined $curr_status && $curr_status eq "PD") {
+	my $OID_info = $self->{'info'}->{$OID};
+	my $curr_status = $OID_info->[INFO_STATUS_INDEX];
+	if($curr_status eq "PD") {
 	    $self->set_info($OID, "D", $self->get_current_time());
 	}
@@ -382,11 +330,4 @@
 }
 
-# find the OID, if it exists, make its status=E for existing.
-sub Xset_status_to_existing_if_OID_present {
-    my $self = shift (@_);
-    my ($OID) = @_;
-
-    $self->set_status_info($OID, "E"); # will only set it if OID exists
-}
 
 ##################### GENERAL, NOT SPECIFIC TO PD-STEP ####################
@@ -438,5 +379,4 @@
 
 }
-
 
 # Does the same as index():
@@ -489,10 +429,9 @@
 	    @lineparts = split ("\t", $line);
 	    if (scalar(@lineparts) >= 2) {
-		$self->add_info (@lineparts);
+		$self->set_info (@lineparts);
 	    }
 	}
 	close (INFILE);
     }
-
 
 }
@@ -514,5 +453,5 @@
 	my ($timestamp) = ($vals=~/^<timestamp>(.*)$/m);
 	
-	$self->add_info ($oid, $deletion_status, $timestamp);
+	$self->set_info ($oid, $deletion_status, $timestamp);
     }
 }
@@ -599,14 +538,4 @@
 }
 
-sub delete_info {
-    my $self = shift (@_);
-    my ($OID) = @_;
-
-    print STDERR "@@@@ ERROR oaiinfo::delete_info: Not allowed to delete entries in oai DB.\n";
-
-    #if (defined $self->{'info'}->{$OID}) {
-    #	delete $self->{'info'}->{$OID};
-    #}
-}
 
 sub set_info { # sets existing or appends
@@ -620,79 +549,4 @@
 }
 
-sub add_info { # appends iff it doesn't exist already
-    my $self = shift (@_);
-    my ($OID, $del_status, $timestamp) = @_;
-
-    if (defined($self->{'info'}->{$OID})) {
-	print STDERR "@@@@ ERROR oaiinfo::add_info: id $OID already exists. Not adding.\n";
-    } else {
-	$self->set_info($OID, $del_status, $timestamp);
-    }
-}
-
-sub set_status_info {
-    my $self = shift (@_);
-    my ($OID, $del_status) = @_;
-
-    my $OID_info = $self->{'info'}->{$OID};
-    if (defined $OID_info) {
-	$OID_info->[INFO_STATUS_INDEX] = $del_status;
-    }
-    else {
-	print STDERR "oaiinfo::set_status_info: Unable to find OAI document id $OID\n";
-    }
-}
-
-sub get_status_info {
-    my $self = shift (@_);
-    my ($OID) = @_;
-
-    my $del_status = undef;
-
-    my $OID_info = $self->{'info'}->{$OID};
-    if (defined $OID_info) {
-	$del_status = $OID_info->[INFO_STATUS_INDEX];
-    }
-    else {
-	print STDERR "oaiinfo::get_status_info: Unable to find OAI document id $OID\n";	
-    }
-
-    return $del_status;
-}
-
-# if no timestamp provided, uses current timestamp
-sub set_timestamp_info {
-    my $self = shift (@_);
-    my ($OID, $timestamp) = @_;
-
-    my $OID_info = $self->{'info'}->{$OID};
-    if (defined $OID_info) {
-	if(!defined $timestamp) {
-	    $timestamp = $self->get_current_time();
-	}
-	$OID_info->[INFO_TIMESTAMP_INDEX] = $timestamp;
-    }
-    else {
-	print STDERR "oaiinfo::set_timestamp_info: Unable to find OAI document id $OID\n";
-    }
-}
-
-sub get_timestamp_info {
-    my $self = shift (@_);
-    my ($OID) = @_;
-
-    my $timestamp = undef;
-
-    my $OID_info = $self->{'info'}->{$OID};
-    if (defined $OID_info) {
-	$timestamp = $OID_info->[INFO_TIMESTAMP_INDEX];
-    }
-    else {
-	print STDERR "oaiinfo::get_timestamp_info: Unable to find OAI document id $OID\n";
-    }
-
-    return $timestamp;
-}
-
 
 # returns a list of the form [[OID, timestamp, deletion_status], ...]
@@ -714,19 +568,4 @@
 
 
-
-# returns an array/list of the form [deletion_status, timestamp]
-sub get_info {
-    my $self = shift (@_);
-    my ($OID) = @_;
-
-    if (defined $self->{'info'}->{$OID}) {
-	return $self->{'info'}->{$OID};
-    }
-
-    return undef;
-}
-
-
-
 # returns the number of entries so far, including deleted ones
 # http://stackoverflow.com/questions/1109095/how-can-i-find-the-number-of-keys-in-a-hash-in-perl
