Index: gs2-extensions/parallel-building/trunk/src/perllib/cgiactions/baseaction.pm
===================================================================
--- gs2-extensions/parallel-building/trunk/src/perllib/cgiactions/baseaction.pm	(revision 24626)
+++ 	(revision )
@@ -1,496 +1,0 @@
-###########################################################################
-#
-# baseaction.pm -- 
-# A component of the Greenstone digital library software
-# from the New Zealand Digital Library Project at the 
-# University of Waikato, New Zealand.
-#
-# Copyright (C) 2009 New Zealand Digital Library Project
-#
-# This program is free software; you can redistr   te it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-###########################################################################
-
-
-package baseaction;
-
-use strict;
-use util;
-use inexport;
-
-our $authenication_enabled = 0;
-our $mail_enabled = 0;
-
-
-# change this to get these values from a config file
-my $mail_to_address = "user\@server";  # Set this appropriately
-my $mail_from_address = "user\@server";  # Set this appropriately
-my $mail_smtp_server = "smtp.server";  # Set this appropriately
-
-
-
-# Required CGI arguments: "a" for action
-#                         "c" for collection
-# Optional CGI arguemnts: "ts" for timestamp (auto generated is missing)
-#                         "site" (used by Greenstone3)
-
-# allow "un" for username to be optional for now
-
-sub new 
-{
-    my $class = shift (@_);
-    my ($action_table,$gsdl_cgi,$iis6_mode) = @_;
-
-    my $self = { 'gsdl_cgi' => $gsdl_cgi, 
-		 'iis6_mode' => $iis6_mode,
-		 'gsdlhome' => $ENV{'GSDLHOME'} };
-
-    # Retrieve the (required) command CGI argument
-    my $action = $gsdl_cgi->clean_param("a");
-
-    if (!defined $action) {
-	my $err_mess = "No action (a=...) specified.\n";
-	$err_mess .= "\nPossible actions are:\n";
-
-	$err_mess .= "  check-installation\n\n";
-
-	foreach my $a (keys %$action_table) {
-	    $err_mess .= "  $a:\n";
-	    $err_mess .= "    Compulsory args: ";
-	    my @comp_args = ("c");
-	    push(@comp_args,"un") if ($authenication_enabled);
-	    push(@comp_args,@{$action_table->{$a}->{'compulsory-args'}});
-	    $err_mess .= join(", ", @comp_args);
-
-	    $err_mess .= "\n";
-
-	    my @opt_args = ();
-	    push(@opt_args,"un") if (!$authenication_enabled);
-	    push(@opt_args,@{$action_table->{$a}->{'optional-args'}});
-
-	    if (scalar(@opt_args)>0) {
-
-		$err_mess .= "    Optional args  : ";
-		$err_mess .= join(", ", @opt_args);
-		$err_mess .= "\n";
-	    }
-	    $err_mess .= "\n";
-	}
-
-	$gsdl_cgi->generate_message($err_mess);
-	exit(-1);
-	    
-    }
-    $gsdl_cgi->delete("a");
-
-	$self = bless $self, $class;
-
-    # The check-installation command has no arguments
-    if ($action eq "check-installation") {
-	$self->check_installation($gsdl_cgi,$iis6_mode);
-	exit 0;
-    }
-
-	
-    if (!defined $action_table->{$action}) {
-	my $valid_actions = join(", ", keys %$action_table);
-
-	my $err_mess = "Unrecognised action (a=$action) specified.\n";
-	$err_mess .= "Valid actions are: $valid_actions\n";
-
-	$gsdl_cgi->generate_error($err_mess);		
-    }
-
-    
-    my $collect = $gsdl_cgi->clean_param("c");
-    if ((!defined $collect) || ($collect =~ m/^\s*$/)) {
-	$gsdl_cgi->generate_error("No collection specified.");
-    }
-    $gsdl_cgi->delete("c");
-
-    # allow un to be optional for now
-    my $username = $gsdl_cgi->clean_param("un");
-
-
-    # Get then remove the ts (timestamp) argument (since this can mess up 
-    #  other scripts)
-    my $timestamp = $gsdl_cgi->clean_param("ts");
-    if ((!defined $timestamp) || ($timestamp =~ m/^\s*$/)) {
-	# Fall back to using the Perl time() function to generate a timestamp
-	$timestamp = time();  
-    }
-    $gsdl_cgi->delete("ts");
-
-    my $site = undef; 
-    if($gsdl_cgi->greenstone_version() != 2) { 
-	# all GS versions after 2 may define site
-	$site = $gsdl_cgi->clean_param("site");   
-	if (!defined $site) {
-	    $gsdl_cgi->generate_error("No site specified.");
-	}
-	$gsdl_cgi->delete("site");
-    }
-    
-
-    $self->{'action'} = $action;
-    $self->{'collect'} = $collect;
-    $self->{'username'} = $username;
-    $self->{'timestamp'} = $timestamp;
-    $self->{'site'} = $site;
-	  
-    # Locate and store compulsory arguments
-    my $comp_args = $action_table->{$action}->{'compulsory-args'};
-    foreach my $ca (@$comp_args) {
-	if (!defined $gsdl_cgi->param($ca)) {
-	    $gsdl_cgi->generate_error("Compulsory argument '$ca' missing");
-	}
-	else {
-	    $self->{$ca} = $gsdl_cgi->clean_param($ca);
-	    $gsdl_cgi->delete($ca);
-	}
-    }
-
-    # Locate and store optional args if present
-    my $opt_args = $action_table->{$action}->{'optional-args'};
-    foreach my $oa (@$opt_args) {
-	if (defined $gsdl_cgi->param($oa)) {
-	    $self->{$oa} = $gsdl_cgi->clean_param($oa);
-	    $gsdl_cgi->delete($oa);
-	}
-    }
-
-	
-	
-    # Retrieve infodb-type
-    if (defined $collect) {
-	
-	my $opt_site = $self->{'site'} || "";
-	
-	my $inexport = newCGI inexport(ref $self,$collect,$gsdl_cgi,$opt_site);
-	my ($config_filename,$collect_cfg) = $inexport->read_collection_cfg($collect);   
-	$self->{'infodbtype'} = $collect_cfg->{'infodbtype'};
-
-    }
-    
-	
-    return $self;
-}
-
-
-sub do_action
-{
-    my $self = shift @_;
-    my $action = $self->{'action'};
-
-    $action =~ s/-/_/g;
-
-    
-    $self->$action();
-
-}
-
-
-
-
-sub authenticate_user
-{
-    my $self = shift @_;
-    my $username = shift(@_);
-    my $collection = shift(@_);
-
-    my $gsdl_cgi = $self->{'gsdl_cgi'};
-
-    # Remove the pw argument (since this can mess up other scripts)
-    my $user_password = $gsdl_cgi->clean_param("pw");
-    $gsdl_cgi->delete("pw");
-
-    if ((!defined $user_password) || ($user_password =~ m/^\s*$/)) {
-	$gsdl_cgi->generate_error("Authentication failed: no password specified.");
-    }
-
-    my $gsdlhome = $ENV{'GSDLHOME'};
-    my $etc_directory = &util::filename_cat($gsdlhome, "etc");
-    my $users_db_file_path = &util::filename_cat($etc_directory, "users.db");
-
-    # Use db2txt to get the user accounts information
-    my $users_db_content = "";
-    open(USERS_DB, "db2txt \"$users_db_file_path\" |");
-    while (<USERS_DB>) {
-	$users_db_content .= $_;
-    }
-
-    # Get the user account information from the users.db database
-    my %users_db_data = ();
-    foreach my $users_db_entry (split(/-{70}/, $users_db_content)) {
-	if ($users_db_entry =~ /\n?\[(.+)\]\n/) {
-	    $users_db_data{$1} = $users_db_entry;
-	}
-    }
-
-    # Check username
-    my $user_data = $users_db_data{$username};
-    if (!defined $user_data) {
-	$gsdl_cgi->generate_error("Authentication failed: no account for user '$username'.");
-    }
-
-    # Check password
-    my ($valid_user_password) = ($user_data =~ /\<password\>(.*)/);
-    if ($user_password ne $valid_user_password) {
-	$gsdl_cgi->generate_error("Authentication failed: incorrect password.");
-    }
-
-    # Check group
-    my ($user_groups) = ($user_data =~ /\<groups\>(.*)/);
-    if ($collection eq "") {
-	# If we're not editing a collection then the user doesn't need to be in a particular group
-	return $user_groups;  # Authentication successful
-    }
-    foreach my $user_group (split(/\,/, $user_groups)) {
-	# Does this user have access to all collections?
-	if ($user_group eq "all-collections-editor") {
-	    return $user_groups;  # Authentication successful
-	}
-	# Does this user have access to personal collections, and is this one?
-	if ($user_group eq "personal-collections-editor" && $collection =~ /^$username\-/) {
-	    return $user_groups;  # Authentication successful
-	}
-	# Does this user have access to this collection
-	if ($user_group eq "$collection-collection-editor") {
-	    return $user_groups;  # Authentication successful
-	}
-    }
-
-    $gsdl_cgi->generate_error("Authentication failed: user is not in the required group.");
-}
-
-
-
-sub check_installation
-{
-    my $self = shift @_;
-    my $iis6_mode = shift(@_);
-
-    my $gsdl_cgi = $self->{'gsdl_cgi'};
-
-    my $installation_ok = 1;
-    my $installation_status = "";
-
-    print STDOUT "Content-type:text/plain\n\n";
-
-    # Check that Java is installed and accessible
-    my $java = $gsdl_cgi->get_java_path();
-    my $java_command = "$java -version 2>&1";
-
-    # IIS 6: redirecting output from STDERR to STDOUT just doesn't work, so we have to let it go
-    #   directly out to the page
-    if ($iis6_mode)
-    {
-	$java_command = "java -version";
-    }
-
-    my $java_output = `$java_command`;
-    my $java_status = $?;
-    if ($java_status < 0) {
-	# The Java command failed
-	$installation_status = "Java failed -- do you have the Java run-time installed?\n" . $gsdl_cgi->check_java_home() . "\n";
-	$installation_ok = 0;
-    }
-    else {
-	$installation_status = "Java found: $java_output";
-    }
-
-    # Show the values of some important environment variables
-    $installation_status .= "\n";
-    $installation_status .= "GSDLHOME: " . $ENV{'GSDLHOME'} . "\n";
-    $installation_status .= "GSDLOS: " . $ENV{'GSDLOS'} . "\n";
-    $installation_status .= "PATH: " . $ENV{'PATH'} . "\n";
-
-    if ($installation_ok) {
-	print STDOUT $installation_status . "\nInstallation OK!";
-    }
-    else {
-	print STDOUT $installation_status;
-    }
-}
-
-sub lock_collection
-{
-    my $self = shift @_;
-    my $username = shift(@_);
-    my $collection = shift(@_);
-
-    my $gsdl_cgi = $self->{'gsdl_cgi'};
-
-    my $steal_lock = $gsdl_cgi->clean_param("steal_lock");
-    $gsdl_cgi->delete("steal_lock");
-
-    if (!defined $username) {
-	# don't have any user details for current user to compare with
-	# even if there is a lock file
-	# For now, allow the current user access.  Might want to
-	# revisit this in the future.
-	return;
-    }
-
-    my $gsdlhome = $ENV{'GSDLHOME'};
-    my $collection_directory = &util::filename_cat($gsdlhome, "collect", $collection);
-    $gsdl_cgi->checked_chdir($collection_directory);
-
-    # Check if a lock file already exists for this collection
-    my $lock_file_name = "gli.lck";
-    if (-e $lock_file_name) {
-	# A lock file already exists... check if it's ours
-	my $lock_file_content = "";
-	open(LOCK_FILE, "<$lock_file_name");
-	while (<LOCK_FILE>) {
-	    $lock_file_content .= $_;
-	}
-	close(LOCK_FILE);
-
-	# Pick out the owner of the lock file
-	$lock_file_content =~ /\<User\>(.*?)\<\/User\>/;
-	my $lock_file_owner = $1;
-
-	# The lock file is ours, so there is no problem
-	if ($lock_file_owner eq $username) {
-	    return;
-	}
-
-	# The lock file is not ours, so throw an error unless "steal_lock" is set
-	unless (defined $steal_lock) {
-	    $gsdl_cgi->generate_error("Collection is locked by: $lock_file_owner");
-	}
-    }
-
-    my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time);
-    my $current_time = sprintf("%02d/%02d/%d %02d:%02d:%02d", $mday, $mon + 1, $year + 1900, $hour, $min, $sec);
-
-    # Create a lock file for us (in the same format as the GLI) and we're done
-    open(LOCK_FILE, ">$lock_file_name");
-    print LOCK_FILE "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
-    print LOCK_FILE "<LockFile>\n";
-    print LOCK_FILE "    <User>" . $username . "</User>\n";
-    print LOCK_FILE "    <Machine>(Remote)</Machine>\n";
-    print LOCK_FILE "    <Date>" . $current_time . "</Date>\n";
-    print LOCK_FILE "</LockFile>\n";
-    close(LOCK_FILE);
-}
-
-
-# Release the gli.lck otherwise no one else will be able to use the collection again.
-sub unlock_collection
-{
-    my $self = shift @_;
-    my ($username, $collection) = @_;
-    my $gsdl_cgi = $self->{'gsdl_cgi'};
-
-    # Obtain the path to the collection GLI lock file
-    my $lock_file_path = &util::filename_cat($ENV{'GSDLHOME'}, "collect", $collection, "gli.lck");
-
-    # If the lock file does exist, check if it is ours
-    if (-e $lock_file_path)
-    {
-	my $lock_file_content = "";
-	open(LOCK_FILE, "<$lock_file_path");
-	while (<LOCK_FILE>) {
-	    $lock_file_content .= $_;
-	}
-	close(LOCK_FILE);
-
-	# Pick out the owner of the lock file
-	$lock_file_content =~ /\<User\>(.*?)\<\/User\>/;
-	my $lock_file_owner = $1;
-
-	# If we are the owner of this lock, we have the right to delete it
-	if ($lock_file_owner eq $username) {
-            unlink($lock_file_path );
-	}
-        else {
-	    $gsdl_cgi->generate_error("Collection is locked by: $lock_file_owner. Cannot be unlocked");
-        }
-    }
-}
-
-
-sub send_mail
-{
-    my $self = shift @_;
-
-    my ($mail_subject,$mail_content) = @_;
-
-    my $gsdl_cgi = $self->{'gsdl_cgi'};
-
-    my $sendmail_command = "\"".&util::get_perl_exec()."\" -S sendmail.pl";
-    $sendmail_command .= " -to \"" . $mail_to_address . "\"";
-    $sendmail_command .= " -from \"" . $mail_from_address . "\"";
-    $sendmail_command .= " -smtp \"" . $mail_smtp_server . "\"";
-    $sendmail_command .= " -subject \"" . $mail_subject . "\"";
-
-    if (!open(POUT, "| $sendmail_command")) {
-	$gsdl_cgi->generate_error("Unable to execute command: $sendmail_command");
-    }
-    print POUT $mail_content . "\n";
-    close(POUT);
-}
-
-
-
-
-sub run_script
-{
-    my $self = shift @_;
-
-    my ($collect, $site, $script) = @_;
-
-    my $gsdl_cgi = $self->{'gsdl_cgi'};
-
-    my $perl_args = $collect;
-
-    my $collect_dir = $gsdl_cgi->get_collection_dir($site); 
-    $perl_args = "-collectdir \"$collect_dir\" " . $perl_args;
-
-    my $perl_command = "\"".&util::get_perl_exec()."\" -S $script $perl_args";
-
-
-    # IIS 6: redirecting output from STDERR to STDOUT just doesn't work, so
-    # we have to let it go directly out to the page
-
-    if (!$self->{'iis6_mode'})
-    {
-	$perl_command .= " 2>&1";
-    }
-
-    if (!open(PIN, "$perl_command |")) {
-	$gsdl_cgi->generate_error("Unable to execute command: $perl_command");
-    }
-
-    print STDOUT "Content-type:text/plain\n\n";
-    print "$perl_command  \n";
-
-    while (defined (my $perl_output_line = <PIN>)) {
-	print STDOUT $perl_output_line;
-    }
-    close(PIN);
-
-    my $perl_status = $?;
-    if ($perl_status > 0) {
-	$gsdl_cgi->generate_error("Perl failed: $perl_command\n--\nExit status: " . ($perl_status / 256));
-    }
-}
-
-
-
-
-1;
Index: gs2-extensions/parallel-building/trunk/src/perllib/cgiactions/buildaction.pm
===================================================================
--- gs2-extensions/parallel-building/trunk/src/perllib/cgiactions/buildaction.pm	(revision 24626)
+++ 	(revision )
@@ -1,434 +1,0 @@
-###########################################################################
-#
-# buildaction.pm -- 
-# A component of the Greenstone digital library software
-# from the New Zealand Digital Library Project at the 
-# University of Waikato, New Zealand.
-#
-# Copyright (C) 2009 New Zealand Digital Library Project
-#
-# This program is free software; you can redistr   te it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-###########################################################################
-
-package buildaction;
-
-use strict;
-
-use JSON;
-
-use cgiactions::baseaction;
-
-use dbutil;
-use ghtml;
-
-use util;
-
-BEGIN {
-#    unshift (@INC, "$ENV{'GSDLHOME'}/perllib/cpan/perl-5.8");
-    require XML::Rules;
-}
-
-
-@buildaction::ISA = ('baseaction');
-
-
-# 'a' for action, and 'c' for collection are also compulsorary, and
-# added in automatically by baseaction
-
-my $action_table =
-{ 
-    "full-import"          => { 'compulsory-args' => [],
-				'optional-args'   => [] }, 
-    
-    "full-buildcol"        => { 'compulsory-args' => [],
-				'optional-args'   => [] },
-    
-    "full-rebuild"         => { 'compulsory-args' => [],
-				'optional-args'   => [] },
-    
-    
-    "incremental-import"   => { 'compulsory-args' => [],
-				'optional-args'   => [] }, 
-
-    "incremental-buildcol" => { 'compulsory-args' => [],
-				'optional-args'   => [] },
-    
-    "incremental-rebuild" => { 'compulsory-args' => [],
-			       'optional-args'   => [] },
-				   
-    "build-by-manifest" => { 'compulsory-args' => [],
-			       'optional-args'   => ["index-files", "reindex-files", "delete-OIDs"] }
-				   
-};
-
-
-sub new 
-{
-    my $class = shift (@_);
-    my ($gsdl_cgi,$iis6_mode) = @_;
-
-    my $self = new baseaction($action_table,$gsdl_cgi,$iis6_mode);
-
-    return bless $self, $class;
-}
-
-
-sub run_build_cmd
-{
-    my $self = shift @_;
-    my ($cmd) = @_;
-
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdl_home  = $self->{'gsdlhome'};
-
-    my $output = `$cmd 2>&1`;
-    my $status = $?;
-    my $report = undef;
-
-    if ($status == 0) {
-	$report = "Perl build successful: $cmd\n--\n";
-	$report .= "$output\n";
-    }
-    else {
-	$report = "Perl rebuild failed: $cmd\n--\n";
-	$report .= "$output\n";
-	$report .= "Exit status: " . ($status / 256) . "\n";
-##	$report .= $gsdl_cgi->check_perl_home();
-
-#	$report .= "PATH = ". $ENV{'PATH'}. "\n";
-    }
-
-    return($status,$report);
-}
-
-sub full_import
-{
-    my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdl_home  = $self->{'gsdlhome'};
-
-    # Authenticate user if it is enabled
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	&authenticate_user($gsdl_cgi, $username, $collect);
-    }
-	
-    # Obtain the collect dir
-    my $collect_dir = &util::filename_cat($gsdl_home, "collect");
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-
-    my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
-    my $cmd = "\"".&util::get_perl_exec()."\" -S full-import.pl \"$collect\"";
-
-    my ($status,$report) = $self->run_build_cmd($cmd);
-   
-    # Release the lock once it is done
-    $self->unlock_collection($username, $collect);
-
-    if ($status==0) {
-	$gsdl_cgi->generate_ok_message($report);
-    }
-    else {
-	$gsdl_cgi->generate_error($report);
-    }
-
-}
-
-
-sub full_buildcol
-{
-    my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdl_home  = $self->{'gsdlhome'};
-
-    # Authenticate user if it is enabled
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	&authenticate_user($gsdl_cgi, $username, $collect);
-    }
-    
-    # Obtain the collect dir
-    my $collect_dir = &util::filename_cat($gsdl_home, "collect");
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-
-    my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
-    my $cmd = "\"".&util::get_perl_exec()."\" -S full-buildcol.pl \"$collect\"";
-
-    my ($status,$report) = $self->run_build_cmd($cmd);
-   
-    # Release the lock once it is done
-    $self->unlock_collection($username, $collect);
-
-    if ($status==0) {
-	$gsdl_cgi->generate_ok_message($report);
-    }
-    else {
-	$gsdl_cgi->generate_error($report);
-    }
-}
-
-
-sub full_rebuild
-{
-    my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdl_home  = $self->{'gsdlhome'};
-
-    # Authenticate user if it is enabled
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	&authenticate_user($gsdl_cgi, $username, $collect);
-    }
-	
-    # Obtain the collect dir
-    my $collect_dir = &util::filename_cat($gsdl_home, "collect");
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-	
-    my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
-    my $cmd = "\"".&util::get_perl_exec()."\" -S full-rebuild.pl \"$collect\"";
-
-    my ($status,$report) = $self->run_build_cmd($cmd);
-   
-    # Release the lock once it is done
-    $self->unlock_collection($username, $collect);
-
-    if ($status==0) {
-	$gsdl_cgi->generate_ok_message($report);
-    }
-    else {
-	$gsdl_cgi->generate_error($report);
-    }
-}
-
-
-
-sub incremental_import
-{
-    my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdl_home  = $self->{'gsdlhome'};
-
-    # Authenticate user if it is enabled
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	&authenticate_user($gsdl_cgi, $username, $collect);
-    }
-	
-    # Obtain the collect dir
-    my $collect_dir = &util::filename_cat($gsdl_home, "collect");
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-
-
-    my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
-    my $cmd = "\"".&util::get_perl_exec()."\" -S incremental-import.pl \"$collect\"";
-
-    my ($status,$report) = $self->run_build_cmd($cmd);
-   
-    # Release the lock once it is done
-    $self->unlock_collection($username, $collect);
-
-    if ($status==0) {
-	$gsdl_cgi->generate_ok_message($report);
-    }
-    else {
-	$gsdl_cgi->generate_error($report);
-    }
-}
-
-
-sub incremental_buildcol
-{
-    my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdl_home  = $self->{'gsdlhome'};
-
-    # Authenticate user if it is enabled
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	&authenticate_user($gsdl_cgi, $username, $collect);
-    }
-    
-    # Obtain the collect dir
-    my $collect_dir = &util::filename_cat($gsdl_home, "collect");
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-
-
-    my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
-    my $cmd = "\"".&util::get_perl_exec()."\" -S incremental-buildcol.pl \"$collect\"";
-
-    my ($status,$report) = $self->run_build_cmd($cmd);
-   
-    # Release the lock once it is done
-    $self->unlock_collection($username, $collect);
-
-    if ($status==0) {
-	$gsdl_cgi->generate_ok_message($report);
-    }
-    else {
-	$gsdl_cgi->generate_error($report);
-    }
-}
-
-
-sub incremental_rebuild
-{
-    my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdl_home  = $self->{'gsdlhome'};
-
-    # Authenticate user if it is enabled
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	&authenticate_user($gsdl_cgi, $username, $collect);
-    }
-	
-    # Obtain the collect dir
-    my $collect_dir = &util::filename_cat($gsdl_home, "collect");
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-
-
-    my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
-    my $cmd = "\"".&util::get_perl_exec()."\" -S incremental-rebuild.pl \"$collect\"";
-
-    my ($status,$report) = $self->run_build_cmd($cmd);
-   
-    # Release the lock once it is done
-    $self->unlock_collection($username, $collect);
-
-    if ($status==0) {
-	$gsdl_cgi->generate_ok_message($report);
-    }
-    else {
-	$gsdl_cgi->generate_error($report);
-    }
-}
-
-sub build_by_manifest
-{
-	my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdl_home  = $self->{'gsdlhome'};
-
-    # Authenticate user if it is enabled
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	&authenticate_user($gsdl_cgi, $username, $collect);
-    }
-	
-    # Obtain the collect dir
-    my $collect_dir = &util::filename_cat($gsdl_home, "collect");
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-
-	my $if_json_str   = $self->{'index-files'};
-	my $rf_json_str   = $self->{'reindex-files'};
-	my $df_json_str   = $self->{'delete-OIDs'};
-	
-		
-	my $index_files   = (defined $if_json_str) ? decode_json $if_json_str : [];
-	my $reindex_files = (defined $rf_json_str) ? decode_json $rf_json_str : [];
-	my $delete_files  = (defined $df_json_str) ? decode_json $df_json_str : [];
-	
-	my $index_files_xml   = join("\n", map { "    <Filename>$_</Filename>" } @$index_files);
-	my $reindex_files_xml = join("\n", map { "    <Filename>$_</Filename>" } @$reindex_files);
-	my $delete_files_xml  = join("\n", map { "    <OID>$_</OID>" } @$delete_files);
-	
-	my $manifest_filename = &util::get_tmp_filename(".xml");
-	my ($status,$report);
-			
-	if (open(MOUT,">$manifest_filename")) {
-		binmode(MOUT,":utf8");
-		print MOUT <<MOUTRAW;
-<Manifest>
-  <Index>
-$index_files_xml
-  </Index>
-  <Reindex>
-$reindex_files_xml
-  </Reindex>
-  <Delete>
-$delete_files_xml
-  </Delete>
-</Manifest>
-MOUTRAW
-		close(MOUT);
-		
-		## my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
-		my $cmd = "\"".&util::get_perl_exec()."\" -S incremental-rebuild.pl -manifest \"$manifest_filename\" \"$collect\"";
-
-		($status,$report) = $self->run_build_cmd($cmd);
-		
-		if ($status==0) {
-			&util::rm($manifest_filename);
-		}
-	}
-	else {
-		$status = -1;
-		$report = "Failed to open '$manifest_filename' for output\n$!\n";
-	}
-	
-   
-    # Release the lock once it is done
-    $self->unlock_collection($username, $collect);
-
-    if ($status==0) {
-	$gsdl_cgi->generate_ok_message($report);
-    }
-    else {
-	$gsdl_cgi->generate_error($report);
-    }
-	
-	# incremental-rebuild.pl -manifest manifest.xml \"" + _greenstoneCollectionName  + "\"";
- }
-
-
-
-1;
Index: gs2-extensions/parallel-building/trunk/src/perllib/cgiactions/explodeaction.pm
===================================================================
--- gs2-extensions/parallel-building/trunk/src/perllib/cgiactions/explodeaction.pm	(revision 24626)
+++ 	(revision )
@@ -1,507 +1,0 @@
-###########################################################################
-#
-# explodeaction.pm -- 
-# A component of the Greenstone digital library software
-# from the New Zealand Digital Library Project at the 
-# University of Waikato, New Zealand.
-#
-# Copyright (C) 2009 New Zealand Digital Library Project
-#
-# This program is free software; you can redistr   te it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-###########################################################################
-
-package explodeaction;
-
-use strict;
-
-use cgiactions::baseaction;
-
-use dbutil;
-use ghtml;
-use util;
-
-use JSON;
-
-use File::Basename;
-
-BEGIN {
-#    unshift (@INC, "$ENV{'GSDLHOME'}/perllib/cpan/perl-5.8");
-    require XML::Rules;
-}
-
-
-@explodeaction::ISA = ('baseaction');
-
-
-# 'a' for action, and 'c' for collection are also compulsorary, and
-# added in automatically by baseaction
-
-my $action_table =
-{ 
-    "explode-document"          => { 'compulsory-args' => ["d"],
-			    'optional-args'   => [] },
-	"delete-document"           => { 'compulsory-args' => ["d"],
-			    'optional-args'   => [ "onlyadd" ] },
-	"delete-document-array"     => { 'compulsory-args' => ["json"],
-			    'optional-args'   => [ "onlyadd" ] }
-				
-				
-};
-
-
-sub new 
-{
-    my $class = shift (@_);
-    my ($gsdl_cgi,$iis6_mode) = @_;
-
-    my $self = new baseaction($action_table,$gsdl_cgi,$iis6_mode);
-
-    return bless $self, $class;
-}
-
-
-sub get_infodb_type
-{
-    my ($opt_site,$collect_home,$collect) = @_;
-
-    my $out = "STDERR";
-
-    $collect = &colcfg::use_collection($opt_site, $collect, $collect_home);
-
-    if ($collect eq "") {
-	print STDERR "Error: failed to find collection $collect in $collect_home\n";
-	print STDOUT "Content-type:text/plain\n\n";
-	print STDOUT "ERROR: Failed to find collection $collect\n";
-	exit 0;
-	
-    }
-
-    # Read in the collection configuration file.
-    my ($config_filename, $gs_mode) = &colcfg::get_collect_cfg_name($out);
-    my $collectcfg = &colcfg::read_collection_cfg ($config_filename, $gs_mode);
-
-    return $collectcfg->{'infodbtype'};
-}
-
-
-sub docid_to_import_filenames
-{
-    my $self = shift @_;
-
-    my @docids = @_;
-
-	my $collect   = $self->{'collect'};
-	my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $infodb_type = $self->{'infodbtype'};
-
-    # Derive the archives dir    
-	my $site = $self->{'site'};
-	my $collect_dir = $gsdl_cgi->get_collection_dir($site);
-	my $archive_dir = &util::filename_cat($collect_dir,$collect,"archives");
-    ##my $archive_dir = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"archives");
-
-    my $arcinfo_doc_filename 
-	= &dbutil::get_infodb_file_path($infodb_type, "archiveinf-doc", 
-					$archive_dir);
-
-    my %all_import_file_keys = ();
-    
-    foreach my $docid (@docids) {
-	# Obtain the src and associated files specified docID
-	
-	my $doc_rec
-	    = &dbutil::read_infodb_entry($infodb_type, $arcinfo_doc_filename, 
-					 $docid);
-	
-	my $src_files = $doc_rec->{'src-file'};
-	my $assoc_files = $doc_rec->{'assoc-file'};
-	
-	if (defined $src_files) {
-	    foreach my $if (@$src_files) {
-		$all_import_file_keys{$if} = 1;
-	    }
-	}
-
-	if (defined $assoc_files) {
-	    foreach my $if (@$assoc_files) {
-		$all_import_file_keys{$if} = 1;
-	    }
-	}
-    }
-
-    my @all_import_files = keys %all_import_file_keys;
-
-    return \@all_import_files;
-}
-
-
-sub import_filenames_to_docids
-{
-    my $self = shift @_;
-    my ($import_filenames) = @_;
-
-	my $collect   = $self->{'collect'};   
-	my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $infodb_type = $self->{'infodbtype'};
-
-    # Derive the archives dir    
-	my $site = $self->{'site'};
-	my $collect_dir = $gsdl_cgi->get_collection_dir($site);
-	my $archive_dir = &util::filename_cat($collect_dir,$collect,"archives");
-    ##my $archive_dir = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"archives");
-
-    # Obtain the oids for the specified import filenames
-    my $arcinfo_src_filename 
-	= &dbutil::get_infodb_file_path($infodb_type, "archiveinf-src", 
-				 	$archive_dir);
-
-    my %all_oid_keys = ();
-
-    foreach my $if (@$import_filenames) {
-		$if = &util::upgrade_if_dos_filename($if);
-
-	print STDERR "*** looking import filename key \"$if\"\n";
-
-	my $src_rec
-	    = &dbutil::read_infodb_entry($infodb_type, $arcinfo_src_filename, 
-					 $if);
-	my $oids = $src_rec->{'oid'};
-
-	foreach my $o (@$oids) {
-	    $all_oid_keys{$o} = 1;
-	}
-    }
-
-    my @all_oids = keys %all_oid_keys;
-
-    return \@all_oids;
-}
-
-
-sub remove_import_filenames
-{
-    my $self = shift @_;
-    my ($expanded_import_filenames) = @_;
-
-    foreach my $f (@$expanded_import_filenames) {
-	# If this document has been exploded before then
-	# its original source files will have already been removed	
-	if (-e $f) {
-	    &util::rm($f);
-	}
-    }
-}
-
-sub move_docoids_to_import
-{
-    my $self = shift @_;
-    my ($docids) = @_;
-
-	my $collect   = $self->{'collect'};
-	my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $infodb_type = $self->{'infodbtype'};
-
-    # Derive the archives and import directories
-	my $site = $self->{'site'};
-	my $collect_dir = $gsdl_cgi->get_collection_dir($site);
-	
-    my $archive_dir = &util::filename_cat($collect_dir,$collect,"archives");
-    my $import_dir  = &util::filename_cat($collect_dir,$collect,"import");
-
-    # Obtain the doc.xml path for the specified docID
-    my $arcinfo_doc_filename 
-	= &dbutil::get_infodb_file_path($infodb_type, "archiveinf-doc", 
-				 	$archive_dir);
-
-    foreach my $docid (@$docids) {
-
-	my $doc_rec
-	    = &dbutil::read_infodb_entry($infodb_type, $arcinfo_doc_filename, 
-					 $docid);
-
-	my $doc_xml_file = $doc_rec->{'doc-file'}->[0];
-
-	# The $doc_xml_file is relative to the archives, so need to do
-	# a bit more work to make sure the right folder containing this
-	# is moved to the right place in the import folder
-
-	my $assoc_path = dirname($doc_xml_file);
-	my $import_assoc_dir = &util::filename_cat($import_dir,$assoc_path);
-	my $archive_assoc_dir = &util::filename_cat($archive_dir,$assoc_path);
-
-	# If assoc_path involves more than one sub directory, then need to make
-	# sure the necessary directories exist in the import area also.
-	# For example, if assoc_path is "a/b/c.dir" then need "import/a/b" to
-	# exists before moving "archives/a/b/c.dir" -> "import/a/b"
-	my $import_target_parent_dir = dirname($import_assoc_dir);
-
-	if (-d $import_assoc_dir) {
-	    # detected version from previous explode => remove it
-	    &util::rm_r($import_assoc_dir);
-	}
-	else {
-	    # First time => make sure parent directory exists to move 
-	    # "c.dir" (see above) into
-	    
-	    &util::mk_all_dir($import_target_parent_dir);
-	}
-
-	&util::cp_r($archive_assoc_dir,$import_target_parent_dir)
-    }
-}
-
-
-sub remove_docoids
-{
-    my $self = shift @_;
-    my ($docids) = @_;
-
-	my $collect   = $self->{'collect'};
-	my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $infodb_type = $self->{'infodbtype'};
-
-    # Derive the archives and import directories
-	my $site = $self->{'site'};
-	my $collect_dir = $gsdl_cgi->get_collection_dir($site);
-	
-    my $archive_dir = &util::filename_cat($collect_dir,$collect,"archives");
-
-    # Obtain the doc.xml path for the specified docID
-    my $arcinfo_doc_filename 
-	= &dbutil::get_infodb_file_path($infodb_type, "archiveinf-doc", 
-				 	$archive_dir);
-
-    foreach my $docid (@$docids) {
-
-		my $doc_rec
-			= &dbutil::read_infodb_entry($infodb_type, $arcinfo_doc_filename, 
-					 $docid);
-
-		my $doc_xml_file = $doc_rec->{'doc-file'}->[0];
-
-		# The $doc_xml_file is relative to the archives, so need to do
-		# a bit more work to make sure the right folder containing this
-		# is moved to the right place in the import folder
-
-		my $assoc_path = dirname($doc_xml_file);
-		my $archive_assoc_dir = &util::filename_cat($archive_dir,$assoc_path);
-
-		&util::rm_r($archive_assoc_dir)
-    }
-}
-
-
-sub explode_document 
-{
-    my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdl_home  = $self->{'gsdlhome'};
-
-    # Authenticate user if it is enabled
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	&authenticate_user($gsdl_cgi, $username, $collect);
-    }
-	
-    # Derive the archives dir    
-	my $site = $self->{'site'};
-	my $collect_dir = $gsdl_cgi->get_collection_dir($site);
-	
-	my $archive_dir = &util::filename_cat($collect_dir,$collect,"archives");
-    ##my $archive_dir = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"archives");
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-
-    # look up additional args
-    my $docid  = $self->{'d'};
-    if ((!defined $docid) || ($docid =~ m/^\s*$/)) {
-	$self->unlock_collection($username, $collect);
-	$gsdl_cgi->generate_error("No docid (d=...) specified.");
-    }
-
-    my ($docid_root,$docid_secnum) = ($docid =~ m/^(.*?)(\..*)?$/);
-
-    my $orig_import_filenames = $self->docid_to_import_filenames($docid_root);
-    my $docid_keys = $self->import_filenames_to_docids($orig_import_filenames);
-    my $expanded_import_filenames = $self->docid_to_import_filenames(@$docid_keys);
-
-    $self->remove_import_filenames($expanded_import_filenames);
-    $self->move_docoids_to_import($docid_keys);
-
-    # Release the lock once it is done
-    $self->unlock_collection($username, $collect);
-
-    my $mess = "Base Doc ID: $docid_root\n-----\n";
-    $mess .= join("\n",@$expanded_import_filenames);
-
-    $gsdl_cgi->generate_ok_message($mess);
-
-}
-
-
-sub delete_document_entry
-{
-	my $self = shift @_;
-	my ($docid_root,$opt_onlyadd) = @_;
-	
-	my $docid_keys = [];
-	if ((defined $opt_onlyadd) && ($opt_onlyadd==1)) {
-		# delete docoid archive folder
-		push(@$docid_keys,$docid_root);
-	}
-	else {
-		print STDERR "**** Not currently implemented for the general case!!\nDeleting 'archive' version only.";
-		
-		push(@$docid_keys,$docid_root);
-		
-		#my $orig_import_filenames = $self->docid_to_import_filenames($docid_root);
-		#$docid_keys = $self->import_filenames_to_docids($orig_import_filenames);
-		#my $expanded_import_filenames = $self->docid_to_import_filenames(@$docid_keys);
-		
-		# need to remove only the files that are not 
-		
-		#$self->remove_import_filenames($expanded_import_filenames);
-	}
-   
-	$self->remove_docoids($docid_keys);
-}
-	
-
-sub delete_document
-{
-    my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdl_home  = $self->{'gsdlhome'};
-
-    # Authenticate user if it is enabled
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	&authenticate_user($gsdl_cgi, $username, $collect);
-    }
-	
-    # Derive the archives dir    
-	my $site = $self->{'site'};
-	my $collect_dir = $gsdl_cgi->get_collection_dir($site);
-	
-	my $archive_dir = &util::filename_cat($collect_dir,$collect,"archives");
-    ##my $archive_dir = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"archives");
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-
-    # look up additional args
-    my $docid  = $self->{'d'};
-    if ((!defined $docid) || ($docid =~ m/^\s*$/)) {
-	$self->unlock_collection($username, $collect);
-	$gsdl_cgi->generate_error("No docid (d=...) specified.");
-    }
-
-    my ($docid_root,$docid_secnum) = ($docid =~ m/^(.*?)(\..*)?$/);
-
-	my $onlyadd = $self->{'onlyadd'};
-
-	my $status = $self->delete_document_entry($docid_root,$onlyadd);	
-
-    # Release the lock once it is done
-    $self->unlock_collection($username, $collect);
-
-	my $mess = "delete-document successful: Key[$docid_root]\n";
-    $gsdl_cgi->generate_ok_message($mess);
-
-}
-
-
-sub delete_document_array
-{
-    my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdlhome  = $self->{'gsdlhome'};
-
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	&authenticate_user($gsdl_cgi, $username, $collect);
-    }
-
-	my $site = $self->{'site'};
-	my $collect_dir = $gsdl_cgi->get_collection_dir($site);
-	
-    $gsdl_cgi->checked_chdir($collect_dir);
-
-    # Obtain the collect dir
-    ## my $collect_dir = &util::filename_cat($gsdlhome, "collect");
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-
-    # look up additional args
-	
-	my $json_str      = $self->{'json'};
-	my $doc_array = decode_json $json_str;
-
-	my $onlyadd = $self->{'onlyadd'};
-	
-	
-	my $global_status = 0;
-	my $global_mess = "";
-	
-	my @all_docids = ();
-	
-	foreach my $doc_array_rec ( @$doc_array ) {
-		
-		my $docid     = $doc_array_rec->{'docid'};
-		
-		push(@all_docids,$docid);
-		
-		my ($docid_root,$docid_secnum) = ($docid =~ m/^(.*?)(\..*)?$/);
-		  
-		my $status = $self->delete_document_entry($docid_root,$onlyadd);	
-		
-		if ($status != 0) {
-			# Catch error if set infodb entry failed
-			$global_status = $status;
-			$global_mess .= "Failed to delete document key: $docid\n";
-			$global_mess .= "Exit status: $status\n";
-			$global_mess .= "System Error Message: $!\n";
-			$global_mess .= "-" x 20;
-		}
-	}
-
-	if ($global_status != 0) {
-		$global_mess .= "PATH: $ENV{'PATH'}\n";
-		$gsdl_cgi->generate_error($global_mess);
-    }
-    else {
-		my $mess = "delete-document-array successful: Keys[ ".join(", ",@all_docids)."]\n";
-		$gsdl_cgi->generate_ok_message($mess);
-    }
-    
-    # Release the lock once it is done
-    $self->unlock_collection($username, $collect);
-}
-
-
-
-1;
Index: gs2-extensions/parallel-building/trunk/src/perllib/cgiactions/imageaction.pm
===================================================================
--- gs2-extensions/parallel-building/trunk/src/perllib/cgiactions/imageaction.pm	(revision 24626)
+++ 	(revision )
@@ -1,202 +1,0 @@
-###########################################################################
-#
-# imageaction.pm -- 
-# A component of the Greenstone digital library software
-# from the New Zealand Digital Library Project at the 
-# University of Waikato, New Zealand.
-#
-# Copyright (C) 2009 New Zealand Digital Library Project
-#
-# This program is free software; you can redistr   te it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-###########################################################################
-
-package imageaction;
-
-use strict;
-
-use cgiactions::baseaction;
-use util;
-
-@imageaction::ISA = ('baseaction');
-
-
-my $action_table =
-{ 
-    "fit-screen" => { 'compulsory-args' => [ "pageWidth", "pageHeight", 
-					     "assocDir", "assocFile" ],
-		      'optional-args'   => [ "orientation" ] },
-
-};
-
-
-sub new 
-{
-    my $class = shift (@_);
-    my ($gsdl_cgi,$iis6_mode) = @_;
-
-    my $self = new baseaction($action_table,$gsdl_cgi,$iis6_mode);
-
-    return bless $self, $class;
-}
-
-
-
-sub get_mime_type
-{
-    my $self = shift @_;
-
-    my ($file) = @_;
-
-    my %image_mime_re = 
-    (
-	"gif"   => "image/gif",
-	"jpe?g" => "image/jpeg",
-	"png"   => "image/png",
-	"tiff?" => "image/tiff",
-	"bmp"   => "image/bmp"
-    );
-
-    my ($ext) = ($file =~ m/^.*\.(.*)?$/);
-
-    foreach my $re (keys %image_mime_re) {
-	if ($ext =~ m/^$re$/i) {
-	    return $image_mime_re{$re};
-	}
-    }
-
-    return undef;
-}
-
-
-
-
-sub fit_screen
-{
-    my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdlhome  = $self->{'gsdlhome'};
-
-
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	&authenticate_user($gsdl_cgi, $username, $collect);
-    }
-
-    my $site = $self->{'site'};
-    my $collect_directory = $gsdl_cgi->get_collection_dir($site);
-    #my $collect_directory = &util::filename_cat($gsdlhome, "collect");
-#    $gsdl_cgi->checked_chdir($collect_directory);
-
-
-#    # Make sure the collection isn't locked by someone else
-#
-
-    $self->lock_collection($username, $collect);
-
-    # look up additional args
-
-    my $pageWidth  = $self->{'pageWidth'};
-    my $pageHeight = $self->{'pageHeight'};
-    my $assocDir   = $self->{'assocDir'};
-    my $assocFile  = $self->{'assocFile'};
-
-    my $orientation = $self->{'orientation'};
-    $orientation = "portrait" if (!defined $orientation);
-
-    my $toplevel_assoc_dir
-	= &util::filename_cat($collect_directory,$collect,"index","assoc");
-    my $src_full_assoc_filename
-	= &util::filename_cat($toplevel_assoc_dir,$assocDir,$assocFile);
-
-    my $dst_width = $pageWidth;
-    my $dst_height = $pageHeight;
-
-    my $opt_ls = ($orientation eq "landscape") ? "-r" : "";
-    
-    my $dst_file = $dst_width."x".$dst_height."$opt_ls-$assocFile";
-
-    my $dst_full_assoc_filename
-	= &util::filename_cat($toplevel_assoc_dir,$assocDir,$dst_file);
-
-    # **** What if assoc folder is on read-only medium such as CD-ROM?
-    # Should really switch to using some collection specific tmp area
-    # => test if top_level assoc dir has write permission?
-
-    if (!-w $toplevel_assoc_dir) {
-	$gsdl_cgi->generate_error("Cannot write out resized image $dst_full_assoc_filename.");
-    }
-
-    # For now will assume it is writable
-
-    if (!-e $dst_full_assoc_filename) {
-	# generate resized image
-
-	# Better to make sure ImageMagick is installed 
-	
-        my $resize = "-filter Lanczos -resize $dst_width"."x"."$dst_height!";
-	# use of "!" forces convert to produce exactly these dimensions, rather
-	# than preserving aspect ratio.  In actual fact, it is intended that
-	# the width and height values passed in *do* preserve the aspect ratio
-	# Doing it this way makes it easier for the web browser to know (ahead of time) the
-	# width and height of the image that will be generated (useful for putting into
-	# <img> and <div> tags
-
-
-	my $cmd = "\"".&util::get_perl_exec()."\" -S gs-magick.pl convert \"$src_full_assoc_filename\" ";
-	$cmd .= "-rotate 90 " if ($orientation eq "landscape");
-
-	$cmd .= "$resize \"$dst_full_assoc_filename\"";
-
-	`$cmd`;
-
-	# generate resized image in assoc file area (if writable)
-	# otherwise in (collection's??) tmp directory
-    }
-
-    my $mime_type = $self->get_mime_type($dst_file);
-    
-    if (defined $mime_type) {
-	# now output it with suitable mime header
-	print STDOUT "Content-type:$mime_type\n\n";
-
-	if (open(IMGIN,"<$dst_full_assoc_filename")) {
-	    binmode IMGIN;
-	    binmode STDOUT;
-	    
-	    my $data;	     
-	    while (read(IMGIN,$data,1024) != 0) { 
-		print STDOUT $data;
-	    } 
-
-	    close(IMGIN);
-
-	    #system("cat \"$dst_full_assoc_filename\"");
-	}
-	else {
-	    $gsdl_cgi->generate_error("Unable to open $dst_full_assoc_filename for output");
-	}
-    }
-    else {
-	$gsdl_cgi->generate_error("Unrecognised image mime-type for $dst_file");
-    }
-
-}
-
-
-1;
Index: gs2-extensions/parallel-building/trunk/src/perllib/cgiactions/indexaction.pm
===================================================================
--- gs2-extensions/parallel-building/trunk/src/perllib/cgiactions/indexaction.pm	(revision 24626)
+++ 	(revision )
@@ -1,380 +1,0 @@
-###########################################################################
-#
-# indexaction.pm -- 
-# A component of the Greenstone digital library software
-# from the New Zealand Digital Library Project at the 
-# University of Waikato, New Zealand.
-#
-# Copyright (C) 2009 New Zealand Digital Library Project
-#
-# This program is free software; you can redistr   te it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-###########################################################################
-
-
-package indexaction;
-
-
-use strict;
-use util;
-use cgiactions::baseaction;
-
-
-@indexaction::ISA = ('baseaction');
-
-# 'a' for action, and 'c' for collection are also compulsorary, and
-# added in automatically by baseaction
-
-my $action_table =
-{ 
-    "full-import"          => { 'compulsory-args' => [],
-				'optional-args'   => [] }, 
-    
-    "full-buildcol"        => { 'compulsory-args' => [],
-				'optional-args'   => [] },
-    
-    "full-rebuild"         => { 'compulsory-args' => [],
-				'optional-args'   => [] },
-    
-    
-    "incremental-import"   => { 'compulsory-args' => [],
-				'optional-args'   => [] }, 
-
-    "incremental-buildcol" => { 'compulsory-args' => [],
-				'optional-args'   => [] },
-    
-    "incremental-rebuild" => { 'compulsory-args' => [],
-			       'optional-args'   => [] }
-};
-
-
-sub new 
-{
-    my $class = shift (@_);
-    my ($gsdl_cgi,$iis6_mode) = @_;
-
-    my $self = new baseaction($action_table,$gsdl_cgi,$iis6_mode);
-
-    return bless $self, $class;
-}
-
-
-
-
-
-sub run_build_cmd
-{
-    my $self = shift @_;
-    my ($cmd) = @_;
-
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdl_home  = $self->{'gsdlhome'};
-
-    my $output = `$cmd 2>&1`;
-    my $status = $?;
-    my $report = undef;
-
-    if ($status == 0) {
-	$report = "Perl build successful: $cmd\n--\n";
-	$report .= "$output\n";
-    }
-    else {
-	$report = "Perl rebuild failed: $cmd\n--\n";
-	$report .= "$output\n";
-	$report .= "Exit status: " . ($status / 256) . "\n";
-##	$report .= $gsdl_cgi->check_perl_home();
-
-#	$report .= "PATH = ". $ENV{'PATH'}. "\n";
-    }
-
-    return($status,$report);
-}
-
-sub full_import
-{
-    my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdl_home  = $self->{'gsdlhome'};
-
-    # Authenticate user if it is enabled
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	&authenticate_user($gsdl_cgi, $username, $collect);
-    }
-	
-    # Obtain the collect dir
-    my $collect_dir = &util::filename_cat($gsdl_home, "collect");
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-
-    my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
-    my $cmd = "\"".&util::get_perl_exec()."\" -S full-import.pl \"$collect\"";
-
-    my ($status,$report) = $self->run_build_cmd($cmd);
-   
-    # Release the lock once it is done
-    $self->unlock_collection($username, $collect);
-
-    if ($status==0) {
-	$gsdl_cgi->generate_ok_message($report);
-    }
-    else {
-	$gsdl_cgi->generate_error($report);
-    }
-
-}
-
-
-sub full_buildcol
-{
-    my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdl_home  = $self->{'gsdlhome'};
-
-    # Authenticate user if it is enabled
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	&authenticate_user($gsdl_cgi, $username, $collect);
-    }
-    
-    # Obtain the collect dir
-    my $collect_dir = &util::filename_cat($gsdl_home, "collect");
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-
-    my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
-    my $cmd = "\"".&util::get_perl_exec()."\" -S full-buildcol.pl \"$collect\"";
-
-    my ($status,$report) = $self->run_build_cmd($cmd);
-   
-    # Release the lock once it is done
-    $self->unlock_collection($username, $collect);
-
-    if ($status==0) {
-	$gsdl_cgi->generate_ok_message($report);
-    }
-    else {
-	$gsdl_cgi->generate_error($report);
-    }
-}
-
-
-sub full_rebuild
-{
-    my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdl_home  = $self->{'gsdlhome'};
-
-    # Authenticate user if it is enabled
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	&authenticate_user($gsdl_cgi, $username, $collect);
-    }
-	
-    # Obtain the collect dir
-    my $collect_dir = &util::filename_cat($gsdl_home, "collect");
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-
-
-    my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
-    my $cmd = "\"".&util::get_perl_exec()."\" -S full-rebuild.pl \"$collect\"";
-
-    my ($status,$report) = $self->run_build_cmd($cmd);
-   
-    # Release the lock once it is done
-    $self->unlock_collection($username, $collect);
-
-    if ($status==0) {
-	$gsdl_cgi->generate_ok_message($report);
-    }
-    else {
-	$gsdl_cgi->generate_error($report);
-    }
-}
-
-
-
-sub incremental_import
-{
-    my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdl_home  = $self->{'gsdlhome'};
-
-    # Authenticate user if it is enabled
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	&authenticate_user($gsdl_cgi, $username, $collect);
-    }
-	
-    # Obtain the collect dir
-    my $collect_dir = &util::filename_cat($gsdl_home, "collect");
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-
-
-    my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
-    my $cmd = "\"".&util::get_perl_exec()."\" -S incremental-import.pl \"$collect\"";
-
-    my ($status,$report) = $self->run_build_cmd($cmd);
-   
-    # Release the lock once it is done
-    $self->unlock_collection($username, $collect);
-
-    if ($status==0) {
-	$gsdl_cgi->generate_ok_message($report);
-    }
-    else {
-	$gsdl_cgi->generate_error($report);
-    }
-}
-
-
-sub incremental_buildcol
-{
-    my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdl_home  = $self->{'gsdlhome'};
-
-    # timestamp could turn out to be useful, but not used just now
-
-    # Authenticate user if it is enabled
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	&authenticate_user($gsdl_cgi, $username, $collect);
-    }
-    
-    # Obtain the collect dir
-    my $collect_dir = &util::filename_cat($gsdl_home, "collect");
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-
-
-    my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
-    my $cmd = "\"".&util::get_perl_exec()."\" -S incremental-buildcol.pl \"$collect\"";
-
-    my ($status,$report) = $self->run_build_cmd($cmd);
-   
-    # Release the lock once it is done
-    $self->unlock_collection($username, $collect);
-
-    if ($status==0) {
-	$gsdl_cgi->generate_ok_message($report);
-    }
-    else {
-	$gsdl_cgi->generate_error($report);
-    }
-}
-
-
-sub incremental_rebuild
-{
-    my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $timestamp = $self->{'timestamp'};
-    my $site      = $self->{'site'};
-
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdl_home  = $self->{'gsdlhome'};
-
-    # Authenticate user if it is enabled
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	&authenticate_user($gsdl_cgi, $username, $collect);
-    }
-	
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-
-    my $cmd = "\"".&util::get_perl_exec()."\" -S incremental-rebuild.pl \"$collect\"";
-
-    my ($status,$report) = $self->run_build_cmd($cmd);
-   
-    # Release the lock once it is done
-    $self->unlock_collection($username, $collect);
-
-    if ($baseaction::mail_enabled) {
-	$self->send_mail("Remote Greenstone building event", "Incremental building of collection '$collect' complete.");
-    }
-
-    if ($status==0) {
-	$gsdl_cgi->generate_ok_message($report);
-    }
-    else {
-	$gsdl_cgi->generate_error($report);
-    }
-}
-
-
-
-
-sub incremental_rebuild_orig
-{
-    my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $timestamp = $self->{'timestamp'};
-    my $site      = $self->{'site'};
-
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-
-    # timestamp could turn out to be useful, but not used just now
-
-    # don't user authenticate for now
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	$self->authenticate_user($username, $collect);
-    }
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect, $site);
-
-    $self->run_script($collect,$site,"incremental-rebuild.pl");
-
-    if ($baseaction::mail_enabled) {
-	$self->send_mail("Remote Greenstone building event", "Build of collection '$collect' complete.");
-    }
-
-}
-
-
-
-
-
-1;
Index: gs2-extensions/parallel-building/trunk/src/perllib/cgiactions/metadataaction.pm
===================================================================
--- gs2-extensions/parallel-building/trunk/src/perllib/cgiactions/metadataaction.pm	(revision 24626)
+++ 	(revision )
@@ -1,1455 +1,0 @@
-###########################################################################
-#
-# metadataaction.pm -- 
-# A component of the Greenstone digital library software
-# from the New Zealand Digital Library Project at the 
-# University of Waikato, New Zealand.
-#
-# Copyright (C) 2009 New Zealand Digital Library Project
-#
-# This program is free software; you can redistr   te it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-###########################################################################
-
-package metadataaction;
-
-use strict;
-
-use cgiactions::baseaction;
-
-use dbutil;
-use ghtml;
-
-use JSON;
-
-
-BEGIN {
-#    unshift (@INC, "$ENV{'GSDLHOME'}/perllib/cpan/perl-5.8");
-    require XML::Rules;
-}
-
-
-@metadataaction::ISA = ('baseaction');
-
-
-my $action_table =
-{ 
-    "get-live-metadata"     => { 'compulsory-args' => [ "d", "metaname" ],
-			         'optional-args'   => [] }, 
-
-    "get-metadata"          => { 'compulsory-args' => [ "d", "metaname" ],
-			         'optional-args'   => [ "metapos" ] }, 
-
-    "set-live-metadata"     => { 'compulsory-args' => [ "d", "metaname", "metavalue" ],
-			         'optional-args'   => [ ] },
-
-    "set-metadata"          => { 'compulsory-args' => [ "d", "metaname", "metavalue" ],
-			         'optional-args'   => [ "metapos" ] },
-
-	"set-metadata-array"     => { 'compulsory-args' => [ "json" ],
-			         'optional-args'   => [ ] },
-					 
-    "set-archives-metadata" => { 'compulsory-args' => [ "d", "metaname", "metavalue" ],
-			         'optional-args'   => [ "metapos", "metamode" ]
-					  # metamode can be "accumulate", "override",
-				},
-
-    "set-archives-metadata-array" => { 'compulsory-args' => [ "json" ],
-			         'optional-args'   => [ "metamode" ]
-				},
-				
-    "set-import-metadata"   => { 'compulsory-args' => [ "metaname", "metavalue" ],
-			         'optional-args'   => [ "d", "f", "metamode" ]
-				    # metamode can be "accumulate", "override", or "unique-id"
-				 },
-
-
-    "remove-live-metadata"  => { 'compulsory-args' => [ "d", "metaname" ],
-			         'optional-args'   => [ ] },
-
-    "remove-metadata"       => { 'compulsory-args' => [ "d", "metaname" ],
-			         'optional-args'   => [ "metapos" ] },
-
-    "insert-metadata"       => { 'compulsory-args' => [ "d", "metaname", "metavalue" ],
-			         'optional-args'   => [ ]
-			       }
-};
-
-
-sub new 
-{
-    my $class = shift (@_);
-    my ($gsdl_cgi,$iis6_mode) = @_;
-
-    # Treat metavalue specially.  To transmit this through a GET request
-    # the Javascript side has url-encoded it, so here we need to decode
-    # it before proceeding
-
-    my $url_encoded_metavalue = $gsdl_cgi->param("metavalue");
-    my $url_decoded_metavalue = &unicode::url_decode($url_encoded_metavalue,1);
-
-    my $unicode_array = &unicode::utf82unicode($url_decoded_metavalue);
-
-    $url_decoded_metavalue = join("",map(chr($_),@$unicode_array));
-
-    $gsdl_cgi->param("metavalue",$url_decoded_metavalue);
-
-    my $self = new baseaction($action_table,$gsdl_cgi,$iis6_mode);
-
-    return bless $self, $class;
-}
-
-
-sub get_live_metadata
-{
-    my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdlhome  = $self->{'gsdlhome'};
-    my $infodbtype = $self->{'infodbtype'};
-	
-    # live metadata gets/saves value scoped (prefixed) by the current usename 
-    # so (for now) let's not bother to enforce authentication
-
-    # Obtain the collect dir
-	my $site = $self->{'site'};
-	my $collect_dir = $gsdl_cgi->get_collection_dir($site);
-    ## my $collect_dir = &util::filename_cat($gsdlhome, "collect");
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-
-    # look up additional args
-    my $docid  = $self->{'d'};
-    if ((!defined $docid) || ($docid =~ m/^\s*$/)) {
-       $gsdl_cgi->generate_error("No docid (d=...) specified.");
-    }
-
-    # Generate the dbkey
-    my $metaname  = $self->{'metaname'};
-    my $dbkey = "$docid.$metaname";
-
-    # To people who know $collect_tail please add some comments
-    # Obtain path to the database
-    my $collect_tail = $collect;
-    $collect_tail =~ s/^.*[\/|\\]//;
-    my $index_text_directory = &util::filename_cat($collect_dir,$collect,"index","text");
-    my $infodb_file_path = &dbutil::get_infodb_file_path($infodbtype, "live-$collect_tail", $index_text_directory);
-    
-    # Obtain the content of the key
-    my $cmd = "gdbmget $infodb_file_path $dbkey";
-    if (open(GIN,"$cmd |") == 0) {
-        # Catch error if gdbmget failed
-	my $mess = "Failed to get metadata key: $metaname\n";
-	$mess .= "$!\n";
-
-	$gsdl_cgi->generate_error($mess);
-    }
-    else {
-	binmode(GIN,":utf8");
-        # Read everything in and concatenate them into $metavalue
-	my $metavalue = "";
-	my $line;
-	while (defined ($line=<GIN>)) {
-	    $metavalue .= $line;
-	}
-	close(GIN);
-	chomp($metavalue); # Get rid off the tailing newlines
-	$gsdl_cgi->generate_ok_message("$metavalue");
-    }
-
-    # Release the lock once it is done
-    $self->unlock_collection($username, $collect);
-}
-
-
-sub get_metadata
-{
-    my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdlhome  = $self->{'gsdlhome'};
-
-    # Authenticate user if it is enabled
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	&authenticate_user($gsdl_cgi, $username, $collect);
-    }
-
-    # Obtain the collect dir
-	my $site = $self->{'site'};
-	my $collect_dir = $gsdl_cgi->get_collection_dir($site);
-    ##my $collect_dir = &util::filename_cat($gsdlhome, "collect");
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-
-    # look up additional args
-    my $docid     = $self->{'d'};
-    my $metaname  = $self->{'metaname'};
-    my $metapos   = $self->{'metapos'};
-    my $infodbtype = $self->{'infodbtype'};
-
-    # To people who know $collect_tail please add some comments
-    # Obtain path to the database
-    my $collect_tail = $collect;
-    $collect_tail =~ s/^.*[\/\\]//;
-    my $index_text_directory = &util::filename_cat($collect_dir,$collect,"index","text");
-    my $infodb_file_path = &dbutil::get_infodb_file_path($infodbtype, $collect_tail, $index_text_directory);
-
-    # Read the docid entry
-    my $doc_rec = &dbutil::read_infodb_entry($infodbtype, $infodb_file_path, $docid);
-  
-    # Basically loop through and unescape_html the values
-    foreach my $k (keys %$doc_rec) {
-	my @escaped_v = ();
-	foreach my $v (@{$doc_rec->{$k}}) {
-	    my $ev = &ghtml::unescape_html($v);
-	    push(@escaped_v, $ev);
-	}
-	$doc_rec->{$k} = \@escaped_v;
-    }
-
-    # Obtain the specified metadata value
-    $metapos = 0 if (!defined $metapos);
-    my $metavalue = $doc_rec->{$metaname}->[$metapos];
-    $gsdl_cgi->generate_ok_message("$metavalue");
-    
-    # Release the lock once it is done
-    $self->unlock_collection($username, $collect);
-}
-
-
-sub set_live_metadata
-{
-    my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdlhome  = $self->{'gsdlhome'};
-    my $infodbtype = $self->{'infodbtype'};
-  
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	&authenticate_user($gsdl_cgi, $username, $collect);
-    }
-
-    # Obtain the collect dir
-	my $site = $self->{'site'};
-	my $collect_dir = $gsdl_cgi->get_collection_dir($site);
-    ##my $collect_dir = &util::filename_cat($gsdlhome, "collect");
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-
-    # look up additional args
-    my $docid     = $self->{'d'};
-    if ((!defined $docid) || ($docid =~ m/^\s*$/)) {
-      $gsdl_cgi->generate_error("No docid (d=...) specified.");
-    }
-    my $metavalue = $self->{'metavalue'};
-  
-
-    # Generate the dbkey    
-    my $metaname  = $self->{'metaname'};
-    my $dbkey = "$docid.$metaname";
-
-    # To people who know $collect_tail please add some comments
-    # Obtain path to the database
-    my $collect_tail = $collect;
-    $collect_tail =~ s/^.*[\/\\]//;
-    my $index_text_directory = &util::filename_cat($collect_dir,$collect,"index","text");
-    my $infodb_file_path = &dbutil::get_infodb_file_path($infodbtype, "live-$collect_tail", $index_text_directory);
-
-    # Set the new value
-    my $cmd = "gdbmset \"$infodb_file_path\" \"$dbkey\" \"$metavalue\"";
-    my $status = system($cmd);
-    if ($status != 0) {
-        # Catch error if gdbmget failed
-	my $mess = "Failed to set metadata key: $dbkey\n";
-
-	$mess .= "PATH: $ENV{'PATH'}\n";
-	$mess .= "cmd = $cmd\n";
-	$mess .= "Exit status: $status\n";
-	$mess .= "System Error Message: $!\n";
-
-	$gsdl_cgi->generate_error($mess);
-    }
-    else {
-	$gsdl_cgi->generate_ok_message("set-live-metadata successful: Key[$metaname]=$metavalue");
-    }
-    
-    # Release the lock once it is done
-    $self->unlock_collection($username, $collect);
-}
-
-sub set_metadata_entry
-{
-	my $self = shift @_;
-	my ($collect_dir,$collect,$infodbtype,$docid,$metaname,$metapos,$metavalue) = @_;
-	
-    # To people who know $collect_tail please add some comments
-    # Obtain path to the database
-    my $collect_tail = $collect;
-    $collect_tail =~ s/^.*[\/\\]//;
-    my $index_text_directory = &util::filename_cat($collect_dir,$collect,"index","text");
-    my $infodb_file_path = &dbutil::get_infodb_file_path($infodbtype, $collect_tail, $index_text_directory);
-	
-#	print STDERR "**** infodb file path = $infodb_file_path\n";
-#	print STDERR "***** infodb type = $infodbtype\n";
-	
-    # Read the docid entry
-    my $doc_rec = &dbutil::read_infodb_entry($infodbtype, $infodb_file_path, $docid);
-	
-    # Set the metadata value
-    if (defined $metapos) {
-		$doc_rec->{$metaname}->[$metapos] = $metavalue;
-    }
-    else {
-		$doc_rec->{$metaname} = [ $metavalue ];
-    }
- 
-    my $status = &dbutil::set_infodb_entry($infodbtype, $infodb_file_path,$docid,$doc_rec);
-	
-	return $status;
-	
-}
-
-sub set_metadata
-{
-    my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdlhome  = $self->{'gsdlhome'};
-
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	&authenticate_user($gsdl_cgi, $username, $collect);
-    }
-
-	my $site = $self->{'site'};
-	my $collect_dir = $gsdl_cgi->get_collection_dir($site);
-	
-    $gsdl_cgi->checked_chdir($collect_dir);
-
-    # Obtain the collect dir
-    ## my $collect_dir = &util::filename_cat($gsdlhome, "collect");
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-
-    # look up additional args
-    my $docid     = $self->{'d'};
-    my $metaname  = $self->{'metaname'};
-    my $metapos   = $self->{'metapos'};
-    my $metavalue = $self->{'metavalue'};
-    my $infodbtype = $self->{'infodbtype'};
-	
-	my $status = $self->set_metadata_entry($collect_dir,$collect,$infodbtype,$docid,$metaname,$metapos,$metavalue);
-	
-    if ($status != 0) {
-        # Catch error if set infodb entry failed
-	my $mess = "Failed to set metadata key: $docid\n";
-	
-	$mess .= "PATH: $ENV{'PATH'}\n";
-	$mess .= "Exit status: $status\n";
-	$mess .= "System Error Message: $!\n";
-	
-	$gsdl_cgi->generate_error($mess);
-    }
-    else {
-	my $mess = "set-metadata successful: Key[$docid]\n";
-	$mess .= "  $metaname";
-	$mess .= "->[$metapos]" if (defined $metapos);
-	$mess .= " = $metavalue";
-	
-	$gsdl_cgi->generate_ok_message($mess);
-    }
-    
-    # Release the lock once it is done
-    $self->unlock_collection($username, $collect);
-}
-
-
-
-
-sub set_metadata_array
-{
-    my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdlhome  = $self->{'gsdlhome'};
-
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	&authenticate_user($gsdl_cgi, $username, $collect);
-    }
-
-	my $site = $self->{'site'};
-	my $collect_dir = $gsdl_cgi->get_collection_dir($site);
-	
-    $gsdl_cgi->checked_chdir($collect_dir);
-
-    # Obtain the collect dir
-    ## my $collect_dir = &util::filename_cat($gsdlhome, "collect");
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-
-    # look up additional args
-	
-	my $infodbtype = $self->{'infodbtype'};
-	
-	my $json_str      = $self->{'json'};
-	my $doc_array = decode_json $json_str;
-	
-	
-	my $global_status = 0;
-	my $global_mess = "";
-	
-	my @all_docids = ();
-	
-	foreach my $doc_array_rec ( @$doc_array ) {
-		
-		my $docid     = $doc_array_rec->{'docid'};
-		my $metaname  = $doc_array_rec->{'metaname'};
-		my $metapos   = $doc_array_rec->{'metapos'};
-		my $metavalue = $doc_array_rec->{'metavalue'};
-		
-		push(@all_docids,$docid);
-		
-		my $status = $self->set_metadata_entry($collect_dir,$collect,$infodbtype,$docid,$metaname,$metapos,$metavalue);	
-		
-		if ($status != 0) {
-			# Catch error if set infodb entry failed
-			$global_status = $status;
-			$global_mess .= "Failed to set metadata key: $docid\n";
-			$global_mess .= "Exit status: $status\n";
-			$global_mess .= "System Error Message: $!\n";
-			$global_mess .= "-" x 20;
-		}
-	}
-
-	if ($global_status != 0) {
-		$global_mess .= "PATH: $ENV{'PATH'}\n";
-		$gsdl_cgi->generate_error($global_mess);
-    }
-    else {
-		my $mess = "set-metadata-array successful: Keys[ ".join(", ",@all_docids)."]\n";
-		$gsdl_cgi->generate_ok_message($mess);
-    }
-    
-    # Release the lock once it is done
-    $self->unlock_collection($username, $collect);
-}
-
-
-
-sub dxml_metadata
-{
-    my ($tagname, $attrHash, $contextArray, $parentDataArray, $parser) = @_;
-    my $metaname = $parser->{'parameters'}->{'metaname'};
-    my $metamode = $parser->{'parameters'}->{'metamode'};
-    
-    my $opt_doc_secnum = $parser->{'parameters'}->{'secnum'};
-    
-    # Find the right metadata tag and checks if we are going to
-    # override it
-    #
-    # Note: This over writes the first metadata block it
-    # encountered. If there are multiple Sections in the doc.xml, it
-    # might not behave as you would expect
-
-    my $curr_secnum = $parser->{'parameters'}->{'curr_section_num'};
-##    print STDERR "**** checking $opt_doc_secnum <=> $curr_secnum\n";
-##    print STDERR "**** metamode = $metamode\n";
-    
-    if ((!defined $opt_doc_secnum) || ($opt_doc_secnum eq $curr_secnum)) {
-	my $name_attr = $attrHash->{'name'};
-	if (($name_attr eq $metaname) && ($metamode eq "override")) {
-##	    print STDERR "**** got match!!\n";
-	    # Get the value and override the current value
-	    my $metavalue = $parser->{'parameters'}->{'metavalue'};
-	    $attrHash->{'_content'} = $metavalue;
-	    
-	    # Don't want it to wipe out any other pieces of metadata
-	    $parser->{'parameters'}->{'metamode'} = "done";
-	}
-    }
-
-    # RAW is [$tagname => $attrHash] not $tagname => $attrHash!!
-    return [$tagname => $attrHash];
-}
-
-
-sub dxml_description
-{
-    my ($tagname, $attrHash, $contextArray, $parentDataArray, $parser) = @_;
-    my $metamode = $parser->{'parameters'}->{'metamode'};
-
-    # Accumulate the metadata
-    # NOTE: This appends new metadata element to all description fields.
-    # If there are multiple Sections/SubSections, the new metadata block will get appended to all of them
-    if (($metamode eq "accumulate") || ($metamode eq "override")) {
-	# If get to here and metamode is override, the this means there 
-	# was no existing value to overide => treat as an append operation
-
-	# Tack a new metadata tag on to the end of the <Metadata>+ block
-	my $metaname = $parser->{'parameters'}->{'metaname'};
-	my $metavalue = $parser->{'parameters'}->{'metavalue'};
-	
-	my $metadata_attr = { '_content' => $metavalue, 
-			      'name'     => $metaname, 
-			      'mode'     => "accumulate" };
-
-	my $append_metadata = [ "Metadata" => $metadata_attr ];
-	my $description_content = $attrHash->{'_content'};
-
-##	print STDERR "**** appending to doc.xml\n";
-
-	push(@$description_content,"    ", $append_metadata ,"\n        ");
-	$parser->{'parameters'}->{'metamode'} = "done";
-    }
-
-
-    # RAW is [$tagname => $attrHash] not $tagname => $attrHash!!
-    return [$tagname => $attrHash];
-}
-
-
-
-sub dxml_start_section
-{
-    my ($tagname, $attrHash, $contextArray, $parentDataArray, $parser) = @_;
-
-    my $new_depth = scalar(@$contextArray);
-
-    if ($new_depth == 1) {
-	$parser->{'parameters'}->{'curr_section_depth'} = 1;
-	$parser->{'parameters'}->{'curr_section_num'}   = "";
-    }
-
-    my $old_depth  = $parser->{'parameters'}->{'curr_section_depth'};
-    my $old_secnum = $parser->{'parameters'}->{'curr_section_num'};
-
-    my $new_secnum;
-
-    if ($new_depth > $old_depth) {
-	# child subsection
-	$new_secnum = "$old_secnum.1";
-    }
-    elsif ($new_depth == $old_depth) {
-	# sibling section => increase it's value by 1
-	my ($tail_num) = ($old_secnum =~ m/\.(\d+)$/);
-	$tail_num++;
-	$new_secnum = $old_secnum;
-	$new_secnum =~ s/\.(\d+)$/\.$tail_num/;
-    }
-    else {
-	# back up to parent section => lopp off tail
-	$new_secnum = $old_secnum;
-	$new_secnum =~ s/\.\d+$//;
-    }
-
-    $parser->{'parameters'}->{'curr_section_depth'} = $new_depth;
-    $parser->{'parameters'}->{'curr_section_num'}   = $new_secnum;
-
-    print STDERR "*** In Section: $new_secnum\n";
-}
-
-sub edit_xml_file
-{
-    my $self = shift @_;
-    my ($gsdl_cgi, $filename, $start_rules, $rules, $options) = @_;
-
-    # use XML::Rules to add it in (read in and out again)
-    my $parser = XML::Rules->new(start_rules     => $start_rules,
-				 rules           => $rules, 
-				 style           => 'filter',
-                                 output_encoding => 'utf8' );
-
-    my $xml_in = "";
-    if (!open(MIN,"<$filename")) {
-	$gsdl_cgi->generate_error("Unable to read in $filename: $!");
-    }
-    else {
-        # Read all the text in
-	my $line;
-	while (defined ($line=<MIN>)) {
-	    $xml_in .= $line;
-	}
-	close(MIN);
-	
-	my $MOUT;    
-	if (!open($MOUT,">$filename")) {
-	    $gsdl_cgi->generate_error("Unable to write out to $filename: $!");
-	}
-	else {
-	    # Matched lines will get handled by the call backs
-##	    my $xml_out = "";
-
-	    binmode($MOUT,":utf8");
-	    $parser->filter($xml_in,$MOUT, $options);
-
-#	    binmode(MOUT,":utf8");
-#	    print MOUT $xml_out;
-	    close($MOUT);	    
-	}
-    }
-}
-
-
-sub edit_doc_xml
-{
-    my $self = shift @_;
-    my ($gsdl_cgi, $doc_xml_filename, $metaname, $metavalue, $metapos, $metamode, $opt_secnum) = @_;
-
-    # To monitor which section/subsection number we are in
-    my @start_rules = 
-	( 'Section'    => \&dxml_start_section );
-
-    # use XML::Rules to add it in (read in and out again)
-    # Set the call back functions
-    my @rules = 
-	( _default => 'raw',
-	  'Metadata'    => \&dxml_metadata,
-	  'Description' => \&dxml_description);
-	  
-    # Sets the parameters
-    my $options = { 'metaname'  => $metaname,
-		    'metapos'   => $metapos,
-		    'metavalue' => $metavalue,
-		    'metamode'  => $metamode };
-			
-    if (defined $opt_secnum) {
-	$options->{'secnum'} = $opt_secnum;
-    }
-
-    $self->edit_xml_file($gsdl_cgi,$doc_xml_filename,\@start_rules,\@rules,$options);
-}
-
-sub set_archives_metadata_entry
-{
-  	my $self = shift @_;
-	my ($gsdl_cgi,$archive_dir, $collect_dir,$collect, $infodbtype,$docid,$metaname,$metapos,$metavalue,$metamode) = @_;
-	
-    # Obtain the doc.xml path for the specified docID
-    my ($docid_root,$docid_secnum) = ($docid =~ m/^(.*?)(\..*)?$/);
-
-    my $arcinfo_doc_filename = &dbutil::get_infodb_file_path($infodbtype, "archiveinf-doc", $archive_dir);
-    my $doc_rec = &dbutil::read_infodb_entry($infodbtype, $arcinfo_doc_filename, $docid_root);
-    my $doc_xml_file = $doc_rec->{'doc-file'}->[0];
-    
-    # The $doc_xml_file is relative to the archives, and now let's get the full path
-    my $archives_dir = &util::filename_cat($collect_dir,$collect,"archives");    
-    my $doc_xml_filename = &util::filename_cat($archives_dir,$doc_xml_file);
-    
-    # Edit the doc.xml file with the specified metadata name, value and position.
-    # TODO: there is a potential problem here as this edit_doc_xml function 
-    # is assuming the simple doc.xml situation where there is only one Section and no SubSections.
-    # Running import.pl -groupsize will cause this to have multiple sections in one doc.xml
-	
-	print STDERR "** away to call edit_doc_xml\n";
-	
-    $self->edit_doc_xml($gsdl_cgi,$doc_xml_filename,
-			$metaname,$metavalue,$metapos,$metamode,$docid_secnum);
-			
-	print STDERR "*** finished edit_doc_xml\n";
-	
-	return 0; # return 0 for now to indicate no error
-			
-}
-
-
-sub set_archives_metadata
-{
-    my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdlhome  = $self->{'gsdlhome'};
-    my $infodbtype = $self->{'infodbtype'};
-	
-
-	
-    if ($baseaction::authentication_enabled) {
-		# Ensure the user is allowed to edit this collection
-		$self->authenticate_user($username, $collect);
-    }
-
-	my $site = $self->{'site'};
-		
-	# Obtain the collect and archive dir   
-	my $collect_dir = $gsdl_cgi->get_collection_dir($site);	
-	
-    my $archive_dir = &util::filename_cat($collect_dir,$collect,"archives");
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-
-    # look up additional args
-    my $docid  = $self->{'d'};
-    my $metaname   = $self->{'metaname'};
-    my $metavalue  = $self->{'metavalue'};
-	
-    my $metapos    = $self->{'metapos'};
-    $metapos = 0 if (!defined $metapos);
-
-    my $metamode   = $self->{'metamode'};
-    if ((!defined $metamode) || ($metamode =~ m/^\s*$/)) {
-	# make "accumulate" the default (less destructive, as won't actually 
-	# delete any existing values)
-	$metamode = "accumulate";
-    } 
-	
-	my $status = $self->set_archives_metadata_entry($gsdl_cgi,$archive_dir, $collect_dir,$collect, $infodbtype,$docid,
-				$metaname,$metapos,$metavalue,$metamode);
-   
-    # Release the lock once it is done
-    $self->unlock_collection($username, $collect);
-
-	if ($status == 0) {
-		my $mess = "set-archives-metadata successful: Key[$docid]\n";
-		$mess .= "  $metaname";
-		$mess .= "->[$metapos]" if (defined $metapos);
-		$mess .= " = $metavalue";
-		$mess .= " ($metamode)\n";
-	
-		$gsdl_cgi->generate_ok_message($mess);	
-	}
-	else {
-		my $mess .= "Failed to set archives metadata key: $docid\n";
-		$mess .= "Exit status: $status\n";
-		$mess .= "System Error Message: $!\n";
-		$mess .= "-" x 20 . "\n";
-		
-		$gsdl_cgi->generate_error($mess);
-	}
-}
-
-
-sub set_archives_metadata_array
-{
-    my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdlhome  = $self->{'gsdlhome'};
-
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	&authenticate_user($gsdl_cgi, $username, $collect);
-    }
-
-	my $site = $self->{'site'};
-	my $collect_dir = $gsdl_cgi->get_collection_dir($site);
-	
-    $gsdl_cgi->checked_chdir($collect_dir);
-
-    # Obtain the collect dir
-    ## my $collect_dir = &util::filename_cat($gsdlhome, "collect");
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-
-    # look up additional args
-	
-	my $infodbtype = $self->{'infodbtype'};
-
-   my $archive_dir = &util::filename_cat($collect_dir,$collect,"archives");
-	
-	my $json_str      = $self->{'json'};
-	my $doc_array = decode_json $json_str;
-	
-	
-	my $global_status = 0;
-	my $global_mess = "";
-	
-	my @all_docids = ();
-	
-	foreach my $doc_array_rec ( @$doc_array ) {
-		
-		my $docid     = $doc_array_rec->{'docid'};
-		my $metaname  = $doc_array_rec->{'metaname'};
-		my $metapos   = $doc_array_rec->{'metapos'};
-		my $metamode   = $self->{'metamode'};
-		my $metavalue = $doc_array_rec->{'metavalue'};
-		
-		# Some sanity checks
-		$metapos = 0 if (!defined $metapos);
-			
-		if ((!defined $metamode) || ($metamode =~ m/^\s*$/)) {
-			# make "accumulate" the default (less destructive, as won't actually 
-			# delete any existing values)
-			$metamode = "accumulate";
-		} 
-	
-		push(@all_docids,$docid);
-		
-		my $status = $self->set_archives_metadata_entry($gsdl_cgi,$archive_dir, $collect_dir,$collect, $infodbtype,$docid,
-				$metaname,$metapos,$metavalue,$metamode);
-		
-		if ($status != 0) {
-			# Catch error if set infodb entry failed
-			$global_status = $status;
-			$global_mess .= "Failed to set metadata key: $docid\n";
-			$global_mess .= "Exit status: $status\n";
-			$global_mess .= "System Error Message: $!\n";
-			$global_mess .= "-" x 20 . "\n";
-		}
-	}
-
-	if ($global_status != 0) {
-		$global_mess .= "PATH: $ENV{'PATH'}\n";
-		$gsdl_cgi->generate_error($global_mess);
-    }
-    else {
-		my $mess = "set-archives-metadata-array successful: Keys[ ".join(", ",@all_docids)."]\n";
-		$gsdl_cgi->generate_ok_message($mess);
-    }
-    
-    # Release the lock once it is done
-    $self->unlock_collection($username, $collect);
-}
-
-
-sub mxml_metadata
-{
-    my ($tagname, $attrHash, $contextArray, $parentDataArray, $parser) = @_;
-    my $metaname = $parser->{'parameters'}->{'metaname'};
-    my $metamode = $parser->{'parameters'}->{'metamode'};
-
-    # Report error if we don't see FileName tag before this
-    die "Fatel Error: Unexpected metadata.xml structure. Undefind current_file, possiblely encountered Description before FileName" if (!defined($parser->{'parameters'}->{'current_file'}));
-    
-    # Don't do anything if we are not in the right FileSet
-    my $file_regexp = $parser->{'parameters'}->{'current_file'};
-    if ($file_regexp =~ /\.\*/) {
-	# Only interested in a file_regexp if it specifies precisely one
-	# file.  
-	# So, skip anything with a .* in it as it is too general
-	return [$tagname => $attrHash];
-    }
-    my $src_file = $parser->{'parameters'}->{'src_file'};
-    if (!($src_file =~ /$file_regexp/)) {
-	return [$tagname => $attrHash];
-    }
-##    print STDERR "*** mxl metamode = $metamode\n";
-
-    # Find the right metadata tag and checks if we are going to override it
-    my $name_attr = $attrHash->{'name'};
-    if (($name_attr eq $metaname) && ($metamode eq "override")) {
-        # Get the value and override the current value
-	my $metavalue = $parser->{'parameters'}->{'metavalue'};
-	$attrHash->{'_content'} = $metavalue;
-
-##	print STDERR "**** overrideing metadata.xml\n";
-
-	# Don't want it to wipe out any other pieces of metadata
-	$parser->{'parameters'}->{'metamode'} = "done";
-    }
-
-    # RAW is [$tagname => $attrHash] not $tagname => $attrHash!!
-    return [$tagname => $attrHash];
-}
-
-
-sub mxml_description
-{
-    my ($tagname, $attrHash, $contextArray, $parentDataArray, $parser) = @_;
-    my $metamode = $parser->{'parameters'}->{'metamode'};    
-
-    # Failed... Report error if we don't see FileName tag before this
-    die "Fatel Error: Unexpected metadata.xml structure. Undefind current_file, possiblely encountered Description before FileName" if (!defined($parser->{'parameters'}->{'current_file'}));
-
-    # Don't do anything if we are not in the right FileSet
-    my $file_regexp = $parser->{'parameters'}->{'current_file'};
-    if ($file_regexp =~ /\.\*/) {
-	# Only interested in a file_regexp if it specifies precisely one
-	# file.  
-	# So, skip anything with a .* in it as it is too general
-	return [$tagname => $attrHash];
-    }
-    my $src_file = $parser->{'parameters'}->{'src_file'};
-    if (!($src_file =~ /$file_regexp/)) {
-	return [$tagname => $attrHash];
-    }
-
-    # Accumulate the metadata block to the end of the description block
-    # Note: This adds metadata block to all description blocks, so if there are 
-    # multiple FileSets, it will add to all of them
-    if (($metamode eq "accumulate") || ($metamode eq "override")) {
-	# if metamode was "override" but get to here then it failed to
-	# find an item to override, in which case it should append its 
-	# value to the end, just like the "accumulate" mode
-
-	# tack a new metadata tag on to the end of the <Metadata>+ block
-	my $metaname = $parser->{'parameters'}->{'metaname'};
-	my $metavalue = $parser->{'parameters'}->{'metavalue'};
-	
-	my $metadata_attr = { '_content' => $metavalue, 
-			      'name'     => $metaname, 
-			      'mode'     => "accumulate" };
-
-	my $append_metadata = [ "Metadata" => $metadata_attr ];
-	my $description_content = $attrHash->{'_content'};
-
-##	print STDERR "*** appending to metadata.xml\n";
-
-	# append the new metadata element to the end of the current
-	# content contained inside this tag
-	push(@$description_content,"    ", $append_metadata ,"\n        ");
-
-	$parser->{'parameters'}->{'metamode'} = "done";
-    }
-
-    # RAW is [$tagname => $attrHash] not $tagname => $attrHash!!
-    return [$tagname => $attrHash];
-}
-
-
-sub mxml_filename
-{
-    my ($tagname, $attrHash, $contextArray, $parentDataArray, $parser) = @_;
-
-    # Store the filename of the Current Fileset
-    # Note: According to http://greenstone.org/dtd/DirectoryMetadata/1.0/DirectoryMetadata.dtd
-    # FileName tag must come before Description tag
-    $parser->{'parameters'}->{'current_file'} = $attrHash->{'_content'};
-
-    # RAW is [$tagname => $attrHash] not $tagname => $attrHash!!
-    return [$tagname => $attrHash];
-}
-
-
-sub mxml_fileset
-{
-    my ($tagname, $attrHash, $contextArray, $parentDataArray, $parser) = @_;
-
-    # Initilise the current_file
-    # Note: According to http://greenstone.org/dtd/DirectoryMetadata/1.0/DirectoryMetadata.dtd
-    # FileName tag must come before Description tag
-    $parser->{'parameters'}->{'current_file'} = "";
-
-    # RAW is [$tagname => $attrHash] not $tagname => $attrHash!!
-    return [$tagname => $attrHash];
-}
-
-
-sub edit_metadata_xml
-{
-    my $self = shift @_;
-    my ($gsdl_cgi, $metadata_xml_filename, $metaname, $metavalue, $metamode, $src_file) = @_;
-
-    # Set the call-back functions for the metadata tags
-    my @rules = 
-	( _default => 'raw',
-          'FileName' => \&mxml_filename,
-	  'Metadata' => \&mxml_metadata,
-	  'Description' => \&mxml_description,
-          'FileSet' => \&mxml_fileset);
-
-    # use XML::Rules to add it in (read in and out again)
-    my $parser = XML::Rules->new(rules => \@rules, 
-				 style => 'filter',
-                                 output_encoding => 'utf8');
-
-    my $xml_in = "";
-    if (!open(MIN,"<$metadata_xml_filename")) {
-	$gsdl_cgi->generate_error("Unable to read in $metadata_xml_filename: $!");
-    }
-    else {
-        # Read them in
-	my $line;
-	while (defined ($line=<MIN>)) {
-	    $xml_in .= $line;
-	}
-	close(MIN);	
-
-        # Filter with the call-back functions
-	my $xml_out = "";
-
-	my $MOUT;
-	if (!open($MOUT,">$metadata_xml_filename")) {
-	    $gsdl_cgi->generate_error("Unable to write out to $metadata_xml_filename: $!");
-	}
-	else {
-	    binmode($MOUT,":utf8");
-
-            # Some wise person please find out how to keep the DTD and encode lines in after it gets filtered by this XML::Rules
-            # At the moment, I will just hack it!
-            #my $header_with_utf8_dtd = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
-	    #$header_with_utf8_dtd .= "<!DOCTYPE DirectoryMetadata SYSTEM \"http://greenstone.org/dtd/DirectoryMetadata/1.0/DirectoryMetadata.dtd\">";
-            #$xml_out =~ s/\<\?xml\sversion\=\"1.0\"\?\>/$header_with_utf8_dtd/;
-	    #print MOUT $xml_out;
-
-	    $parser->filter($xml_in, $MOUT, { metaname => $metaname,
-					      metavalue => $metavalue,
-					      metamode => $metamode,
-					      src_file => $src_file,
-					      current_file => undef} );
-	    close($MOUT);	    
-	}
-    }
-}
-
-
-sub set_import_metadata
-{
-    my $self = shift @_;
-    
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdlhome  = $self->{'gsdlhome'};
-    my $infodbtype = $self->{'infodbtype'};
-	
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	$self->authenticate_user($username, $collect);
-    }
-
-
-    # Obtain the collect and archive dir    
-	my $site = $self->{'site'};
-	my $collect_dir = $gsdl_cgi->get_collection_dir($site);
-
-    ## my $collect_dir = &util::filename_cat($gsdlhome, "collect");
-    my $archive_dir = &util::filename_cat($collect_dir,$collect,"archives");
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-    
-    # look up additional args
-    # want either d= or f=
-    my $docid  = $self->{'d'};
-    my $import_file  = $self->{'f'};
-    if ((!defined $docid) && (!defined $import_file)) {
-	$gsdl_cgi->generate_error("No docid (d=...) or import file (f=) specified.");
-    } 
-
-    # Get the parameters and set default mode to "accumulate"
-    my $metaname   = $self->{'metaname'};
-    my $metavalue  = $self->{'metavalue'};
-##    $metavalue =~ s/&amp;lt;(.*?)&amp;gt;/<$1>/g;
-    $metavalue =~ s/&lt;(.*?)&gt;/<$1>/g;
-    print STDERR "*** set import meta: val = $metavalue\n";
-    
-    my $metamode   = $self->{'metamode'};
-    if ((!defined $metamode) || ($metamode =~ m/^\s*$/)) {
-	# make "accumulate" the default (less destructive, as won't actually 
-	# delete any existing values)
-	$metamode = "accumulate";
-    }
-
-    # Obtain where the metadata.xml is from the archiveinfo-doc.gdb file
-    # If the doc oid is not specified, we assume the metadata.xml is next to the specified "f"
-    my $metadata_xml_file;
-    my $import_filename = undef;
-    if (defined $docid) {
-	my $arcinfo_doc_filename = &dbutil::get_infodb_file_path($infodbtype, "archiveinf-doc", $archive_dir);
-	my $doc_rec = &dbutil::read_infodb_entry($infodbtype, $arcinfo_doc_filename, $docid);
-
-	# This now stores the full pathname
-	$import_filename = $doc_rec->{'src-file'}->[0];	
-    }
-    else {
-        $import_filename = &util::filename_cat($collect_dir,$collect,$import_file);
-    }
-
-    # figure out correct metadata.xml file [?]
-    # Assuming the metadata.xml file is next to the source file
-    # Note: This will not work if it is using the inherited metadata from the parent folder
-    my ($import_tailname, $import_dirname) 
-	= File::Basename::fileparse($import_filename);
-    my $metadata_xml_filename = &util::filename_cat($import_dirname,"metadata.xml");
-
-    # Edit the metadata.xml
-    # Modified by Jeffrey from DL Consulting
-    # Handle the case where there is one metadata.xml file for multiple FileSets
-    # The XML filter needs to know whether it is in the right FileSet
-    # TODO: This doesn't fix the problem where the metadata.xml is not next to the src file.
-    # TODO: This doesn't handle the common metadata (where FileName doesn't point to a single file)
-    $self->edit_metadata_xml($gsdl_cgi, $metadata_xml_filename,
-                             $metaname, $metavalue, $metamode, $import_tailname);
-
-    # Release the lock once it is done
-    $self->unlock_collection($username, $collect);
-
-    my $mess = "set-import-metadata successful: Key[$docid] -> $metadata_xml_filename\n";
-    $mess .= "  $metaname";
-    $mess .= " = $metavalue";
-    $mess .= " ($metamode)\n";
-	
-    $gsdl_cgi->generate_ok_message($mess);
-    
-}
-
-
-sub remove_live_metadata
-{
-    my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdlhome  = $self->{'gsdlhome'};
-    my $infodbtype = $self->{'infodbtype'};
-	
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	&authenticate_user($gsdl_cgi, $username, $collect);
-    }
-
-    # Obtain the collect dir
-    ## my $collect_dir = &util::filename_cat($gsdlhome, "collect");
-	my $site = $self->{'site'};
-	my $collect_dir = $gsdl_cgi->get_collection_dir($site);
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-
-    # look up additional args
-    my $docid     = $self->{'d'};
-    if ((!defined $docid) || ($docid =~ m/^\s*$/)) {
-      $gsdl_cgi->generate_error("No docid (d=...) specified.");
-    }
-    
-    # Generate the dbkey
-    my $metaname  = $self->{'metaname'};
-    my $dbkey = "$docid.$metaname";
-
-    # To people who know $collect_tail please add some comments
-    # Obtain the live gdbm_db path 
-    my $collect_tail = $collect;
-    $collect_tail =~ s/^.*[\/\\]//;
-    my $index_text_directory = &util::filename_cat($collect_dir,$collect,"index","text");
-    my $infodb_file_path = &dbutil::get_infodb_file_path($infodbtype, "live-$collect_tail", $index_text_directory);
-
-    # Remove the key
-    my $cmd = "gdbmdel \"$infodb_file_path\" \"$dbkey\"";
-    my $status = system($cmd);
-    if ($status != 0) {
-        # Catch error if gdbmdel failed
-	my $mess = "Failed to set metadata key: $dbkey\n";
-	
-	$mess .= "PATH: $ENV{'PATH'}\n";
-	$mess .= "cmd = $cmd\n";
-	$mess .= "Exit status: $status\n";
-	$mess .= "System Error Message: $!\n";
-
-	$gsdl_cgi->generate_error($mess);
-    }
-    else {
-	$gsdl_cgi->generate_ok_message("DB remove successful: Key[$metaname]");
-    }
-
-}
-
-
-sub remove_metadata
-{
-    my $self = shift @_;
-
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdlhome  = $self->{'gsdlhome'};
-    my $infodbtype = $self->{'infodbtype'};
-	
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	&authenticate_user($gsdl_cgi, $username, $collect);
-    }
-
-    # Obtain the collect dir
-	my $site = $self->{'site'};
-	my $collect_dir = $gsdl_cgi->get_collection_dir($site);
-    ## my $collect_dir = &util::filename_cat($gsdlhome, "collect");
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-
-    # look up additional args
-    my $docid     = $self->{'d'};
-    if ((!defined $docid) || ($docid =~ m/^\s*$/)) {
-      $gsdl_cgi->generate_error("No docid (d=...) specified.");
-    }
-    my $metaname  = $self->{'metaname'};
-    my $metapos   = $self->{'metapos'};
-
-    # To people who know $collect_tail please add some comments
-    # Obtain the path to the database
-    my $collect_tail = $collect;
-    $collect_tail =~ s/^.*[\/\\]//;
-    my $index_text_directory = &util::filename_cat($collect_dir,$collect,"index","text");
-    my $infodb_file_path = &dbutil::get_infodb_file_path($infodbtype, $collect_tail, $index_text_directory);
-
-    # Read the docid entry
-    my $doc_rec = &dbutil::read_infodb_entry($infodbtype, $infodb_file_path, $docid);
-
-    # Basically loop through and unescape_html the values
-    foreach my $k (keys %$doc_rec) {
-	my @escaped_v = ();
-	foreach my $v (@{$doc_rec->{$k}}) {
-	    if ($k eq "contains") {
-		# protect quotes in ".2;".3 etc
-		$v =~ s/\"/\\\"/g;
-		push(@escaped_v, $v);
-	    }
-	    else {
-		my $ev = &ghtml::unescape_html($v);
-		$ev =~ s/\"/\\\"/g;
-		push(@escaped_v, $ev);
-	    }
-	}
-	$doc_rec->{$k} = \@escaped_v;
-    }
-
-    # Check to make sure the key does exist
-    if (!defined ($doc_rec->{$metaname})) {
-        $gsdl_cgi->generate_error("No metadata field \"" . $metaname . "\" in the specified document: [" . $docid . "]");
-    }
-
-    # Obtain the specified metadata pos
-    $metapos = 0 if (!defined $metapos);
-
-    # consider check key is defined before deleting?
-    # Loop through the metadata array and ignore the specified position
-    my $filtered_metadata = [];
-    my $num_metadata_vals = scalar(@{$doc_rec->{$metaname}});    
-    for (my $i=0; $i<$num_metadata_vals; $i++) {
-	my $metavalue = shift(@{$doc_rec->{$metaname}});
-
-	if ($i != $metapos) {
-	    push(@$filtered_metadata,$metavalue)
-	}
-    }
-    $doc_rec->{$metaname} = $filtered_metadata;
-
-    # Turn the record back to string
-    my $serialized_doc_rec = &dbutil::convert_infodb_hash_to_string($doc_rec);
-
-    # Store it back to the database
-    my $cmd = "gdbmset \"$infodb_file_path\" \"$docid\" \"$serialized_doc_rec\"";
-    my $status = system($cmd);
-    if ($status != 0) {
-	my $mess = "Failed to set metadata key: $docid\n";
-	
-	$mess .= "PATH: $ENV{'PATH'}\n";
-	$mess .= "cmd = $cmd\n";
-	$mess .= "Exit status: $status\n";
-	$mess .= "System Error Message: $!\n";
-
-	$gsdl_cgi->generate_error($mess);
-    }
-    else {
-	my $mess = "DB set (with item deleted) successful: Key[$docid]\n";
-	$mess .= "  $metaname";
-	$mess .= "->[$metapos]" if (defined $metapos);
-
-	$gsdl_cgi->generate_ok_message($mess);
-    }
-}
-
-
-# Was trying to reused the codes, but the functions need to be broken
-# down more before they can be reused, otherwise there will be too
-# much overhead and duplicate process...
-sub insert_metadata
-{
-    my $self = shift @_;
-    
-    my $username  = $self->{'username'};
-    my $collect   = $self->{'collect'};
-    my $gsdl_cgi  = $self->{'gsdl_cgi'};
-    my $gsdlhome  = $self->{'gsdlhome'};
-    my $infodbtype = $self->{'infodbtype'};
-	
-    # If the import metadata and gdbm database have been updated, we
-    # need to insert some notification to warn user that the the text
-    # they see at the moment is not indexed and require a rebuild.
-    my $rebuild_pending_macro = "_rebuildpendingmessage_";
-
-    if ($baseaction::authentication_enabled) {
-	# Ensure the user is allowed to edit this collection
-	$self->authenticate_user($username, $collect);
-    }
-
-    # Obtain the collect and archive dir   
-	my $site = $self->{'site'};
-	my $collect_dir = $gsdl_cgi->get_collection_dir($site);
-    ##my $collect_dir = &util::filename_cat($gsdlhome, "collect");
-    my $archive_dir = &util::filename_cat($collect_dir,$collect,"archives");
-
-    # Make sure the collection isn't locked by someone else
-    $self->lock_collection($username, $collect);
-    
-    # Check additional args
-    my $docid = $self->{'d'};
-    if (!defined($docid)) {
-	$gsdl_cgi->generate_error("No document id is specified: d=...");
-    } 
-    my $metaname = $self->{'metaname'};
-    if (!defined($metaname)) {
-	$gsdl_cgi->generate_error("No metaname is specified: metadataname=...");
-    } 
-    my $metavalue = $self->{'metavalue'};
-    if (!defined($metavalue) || $metavalue eq "") {
-	$gsdl_cgi->generate_error("No metavalue or empty metavalue is specified: metadataname=...");
-    } 
-    # make "accumulate" the default (less destructive, as won't actually 
-    # delete any existing values)
-    my $metamode = "accumulate";
-
-    #=======================================================================#
-    # set_import_metadata [START]
-    #=======================================================================#
-    # Obtain where the metadata.xml is from the archiveinfo-doc.gdb file
-    # If the doc oid is not specified, we assume the metadata.xml is next to the specified "f"
-    my $metadata_xml_file;
-    my $arcinfo_doc_filename = &dbutil::get_infodb_file_path($infodbtype, "archiveinf-doc", $archive_dir);
-    my $archive_doc_rec = &dbutil::read_infodb_entry($infodbtype, $arcinfo_doc_filename, $docid);
-    
-    # This now stores the full pathname
-    my $import_filename = $archive_doc_rec->{'src-file'}->[0];
-    
-    # figure out correct metadata.xml file [?]
-    # Assuming the metadata.xml file is next to the source file
-    # Note: This will not work if it is using the inherited metadata from the parent folder
-    my ($import_tailname, $import_dirname) 
-	= File::Basename::fileparse($import_filename);
-    my $metadata_xml_filename = &util::filename_cat($import_dirname,"metadata.xml");
-
-    # Shane's escape characters
-    $metavalue = pack "U0C*", unpack "C*", $metavalue;
-    $metavalue =~ s/\,/&#44;/g;
-    $metavalue =~ s/\:/&#58;/g;
-    $metavalue =~ s/\|/&#124;/g;
-    $metavalue =~ s/\(/&#40;/g;
-    $metavalue =~ s/\)/&#41;/g;
-    $metavalue =~ s/\[/&#91;/g;
-    $metavalue =~ s/\\/&#92;/g;
-    $metavalue =~ s/\]/&#93;/g;
-    $metavalue =~ s/\{/&#123;/g;
-    $metavalue =~ s/\}/&#125;/g;
-    $metavalue =~ s/\"/&#34;/g;
-    $metavalue =~ s/\`/&#96;/g;
-    $metavalue =~ s/\n/_newline_/g;
-
-    # Edit the metadata.xml
-    # Modified by Jeffrey from DL Consulting
-    # Handle the case where there is one metadata.xml file for multiple FileSets
-    # The XML filter needs to know whether it is in the right FileSet
-    # TODO: This doesn't fix the problem where the metadata.xml is not next to the src file.
-    # TODO: This doesn't handle the common metadata (where FileName doesn't point to a single file)
-    $self->edit_metadata_xml($gsdl_cgi, $metadata_xml_filename,
-                             $metaname, $metavalue, $metamode, $import_tailname);
-    #=======================================================================#
-    # set_import_metadata [END]
-    #=======================================================================#
-
-
-    #=======================================================================#
-    # set_metadata (accumulate version) [START]
-    #=======================================================================#
-    # To people who know $collect_tail please add some comments
-    # Obtain path to the database
-    my $collect_tail = $collect;
-    $collect_tail =~ s/^.*[\/\\]//;
-    my $index_text_directory = &util::filename_cat($collect_dir,$collect,"index","text");
-    my $infodb_file_path = &dbutil::get_infodb_file_path($infodbtype, $collect_tail, $index_text_directory);
-
-    # Read the docid entry
-    my $doc_rec = &dbutil::read_infodb_entry($infodbtype, $infodb_file_path, $docid);
-   
-    foreach my $k (keys %$doc_rec) {
-	my @escaped_v = ();
-	foreach my $v (@{$doc_rec->{$k}}) {
-	    if ($k eq "contains") {
-		# protect quotes in ".2;".3 etc
-		$v =~ s/\"/\\\"/g;
-		push(@escaped_v, $v);
-	    }
-	    else {
-		my $ev = &ghtml::unescape_html($v);
-		$ev =~ s/\"/\\\"/g;
-		push(@escaped_v, $ev);
-	    }
-	}
-	$doc_rec->{$k} = \@escaped_v;
-    }
-
-    # Protect the quotes
-    $metavalue =~ s/\"/\\\"/g;
-
-    # Adds the pending macro
-    my $macro_metavalue = $rebuild_pending_macro . $metavalue;
-
-    # If the metadata doesn't exist, create a new one
-    if (!defined($doc_rec->{$metaname})){    
-	$doc_rec->{$metaname} = [ $macro_metavalue ];
-    }
-    # Else, let's acculumate the values
-    else {
-        push(@{$doc_rec->{$metaname}},$macro_metavalue);
-    }
-
-    # Generate the record string
-    my $serialized_doc_rec = &dbutil::convert_infodb_hash_to_string($doc_rec);
-
-    # Store it into GDBM
-    my $cmd = "gdbmset \"$infodb_file_path\" \"$docid\" \"$serialized_doc_rec\"";
-    my $status = system($cmd);
-    if ($status != 0) {
-        # Catch error if gdbmget failed
-	my $mess = "Failed to set metadata key: $docid\n";
-	
-	$mess .= "PATH: $ENV{'PATH'}\n";
-	$mess .= "cmd = $cmd\n";
-	$mess .= "Exit status: $status\n";
-	$mess .= "System Error Message: $!\n";
-
-	$gsdl_cgi->generate_error($mess);
-    }
-    else {
-	my $mess = "insert-metadata successful: Key[$docid]\n";
-	$mess .= "  [In metadata.xml] $metaname";
-	$mess .= " = $metavalue\n";
-	$mess .= "  [In database] $metaname";
-	$mess .= " = $macro_metavalue\n";
-	$mess .= "  The new text has not been indexed, rebuilding collection is required\n";
-        $gsdl_cgi->generate_ok_message($mess);
-    }    
-    #=======================================================================#
-    # set_metadata (accumulate version) [END]
-    #=======================================================================#
-
-    # Release the lock once it is done
-    $self->unlock_collection($username, $collect);
-}
-
-1;
Index: gs2-extensions/parallel-building/trunk/src/perllib/cgiactions/ocraction.pm
===================================================================
--- gs2-extensions/parallel-building/trunk/src/perllib/cgiactions/ocraction.pm	(revision 24626)
+++ 	(revision )
@@ -1,87 +1,0 @@
-package ocraction;
-
-use strict;
-
-use cgiactions::baseaction;
-
-use dbutil;
-use ghtml;
-
-
-BEGIN {
-#    unshift (@INC, "$ENV{'GSDLHOME'}/perllib/cpan/perl-5.8");
-    require XML::Rules;
-}
-
-
-@ocraction::ISA = ('baseaction');
-
-my $action_table =
-{ 
-    "preformOcr"     => { 'compulsory-args' => [ "d", "imagename" ],
-			         'optional-args'   => [] },
-	"setText"		 =>	{ 'compulsory-args' => [ "d", "newtext" ],
-					 'optional-args'   => [] }
-};
-
-sub new 
-{
-    my $class = shift (@_);
-    my ($gsdl_cgi,$iis6_mode) = @_;
-
-    my $self = new baseaction($action_table,$gsdl_cgi,$iis6_mode);
-
-    return bless $self, $class;
-}
-
-sub preformOcr
-{
-	my $self = shift @_;
-
-	my $collection = $self->{'collect'};
-	my $site = $self->{'site'};
-	my $gsdl_cgi  = $self->{'gsdl_cgi'};
-	
-	my $docId = $self->{'d'};
-	my $imagename = $self->{'imagename'};
-
-	# Change URL style '/' to Windows style
-	$imagename =~ s/\//\\/g;
-
-	my $indexDir = "C:\\Users\\Bryce\\Desktop\\Research\\greenstone3-svn-bryce64\\web\\sites\\localsite\\collect\\jonesmin\\";
-	##my $hashDir = $archivesDir . substr($docId,0,8) . ".dir\\";
-
-	my $imageFile = $indexDir . $imagename;
-
-	my $outputFile = $ENV{'TEMP'} . "\\out";
-	my $cmd = "tesseract $imageFile $outputFile";
-	## print STDERR "\n\n CMD=\n$cmd \n\n";
-
-	my $status = system($cmd);
-	if($status != 0) { print STDERR "\n\n Fail to run \n $cmd \n $! \n\n"; }
-	if (open (FILE, "<$outputFile" . ".txt")==0) {
-		$gsdl_cgi->generate_error("Unable to open file containing OCR'd text:<br> $!");
-		return;
-	}
-		
-	my $result = "";
-	my $line;
-	while(defined ($line=<FILE>)) {
-		$result .= $line;
-	}
-	close FILE;
-	unlink($outputFile . ".txt");
-	
-	$gsdl_cgi->generate_ok_message($result);
-}
-
-sub setText
-{
-	my $self = shift @_;
-	my $collection = $self->{'collect'};
-	my $site = $self->{'site'};
-	my $docId = $self->{'d'};
-	my $newtext = $self->{'newtext'};
-}
-
-1;
