Index: main/trunk/greenstone2/perllib/plugouts/BasePlugout.pm
===================================================================
--- main/trunk/greenstone2/perllib/plugouts/BasePlugout.pm	(revision 28006)
+++ main/trunk/greenstone2/perllib/plugouts/BasePlugout.pm	(revision 28021)
@@ -93,5 +93,5 @@
 	 'type' => "flag",
 	 'reqd' => "no",
-         'deft' => "false",
+         'deft' => "0",
 	 'hiddengli' => "no"},
        { 'name' => 'no_rss',
@@ -158,7 +158,7 @@
     }
 
-    $self->{'gs_count'} = 0;    
-
-    $self->{'keep_import_structure'} = 0; 
+    $self->{'gs_count'} = 0;
+
+    $self->{'keep_import_structure'} = 0;
 
     return bless $self, $class;
@@ -171,5 +171,5 @@
     my $header = shift(@_);
     my $high_level_information_only = shift(@_);
-    
+
     # XML output is always in UTF-8
     gsprintf::output_strings_in_UTF8;
@@ -670,6 +670,12 @@
 # Once a doc object is ready to write to disk (and hence has a nice OID),
 # generate a unique subdirectory to write the information to.
+#
 # - create the directory as part of this call, to try and avoid race conditions
 #   found in parallel processing [jmt12]
+#
+# @todo figure out what the rule regarding $work_info->size() is meant to do
+#
+# @todo determine what $self->{'group'} is, and whether it should affect
+#       directory creation
 #
 sub get_new_doc_dir
@@ -704,12 +710,19 @@
       $doc_dir .= '/';
     }
+
     # the default matching pattern grabs the next 'subdir_split_length'
     # characters of the OID to act as the next subdirectory
     my $pattern = '^(.{1,' . $self->{'subdir_split_length'} . '})';
+
     # Do we count any "HASH" prefix against the split length limit?
+    print "[DEBUG] SubDir Hash Prefix: |" . $self->{'subdir_hash_prefix'} . "|\n";
     if ($self->{'subdir_hash_prefix'} && $doc_dir_num == 0)
     {
       $pattern = '^((HASH)?.{1,' . $self->{'subdir_split_length'} . '})';
     }
+
+    print "[DEBUG] Pattern: |" . $pattern . "|\n";
+
+
     # Note the use of 's' to both capture the next chuck of OID and to remove
     # it from OID at the same time
@@ -718,16 +731,18 @@
       $doc_dir .= $1;
       $doc_dir_num++;
-	  my $full_doc_dir = &FileUtils::filenameConcatenate($working_dir, $doc_dir . '.dir');
-	  if(!FileUtils::directoryExists($full_doc_dir)) {
-		&FileUtils::makeAllDirectories($full_doc_dir);
-		$created_directory = 1;
-	  }
-    }
-    ###my $new_dir = &FileUtils::filenameConcatenate($working_dir, $doc_dir . '.dir');
-    ###rint STDERR "[DEBUG] BasePlugout::get_new_doc_dir(<working_info>, $working_dir, $oid)\n";
-    ###rint STDERR " - create directory: $new_dir => $created_directory\n";
-    ###rint STDERR " - rest: $doc_dir_rest\n";
-    ###rint STDERR " - working_info->size(): " . $working_info->size() . " [ < 1024 ?]\n";
-    ###rint STDERR " - doc_dir_num: " . $doc_dir_num . "\n";
+
+      my $full_doc_dir = &FileUtils::filenameConcatenate($working_dir, $doc_dir . '.dir');
+      if(!FileUtils::directoryExists($full_doc_dir))
+      {
+        &FileUtils::makeAllDirectories($full_doc_dir);
+        $created_directory = 1;
+      }
+
+      ###rint STDERR "[DEBUG] BasePlugout::get_new_doc_dir(<working_info>, $working_dir, $oid)\n";
+      ###rint STDERR " - create directory: $full_doc_dir => $created_directory\n";
+      ###rint STDERR " - rest: $doc_dir_rest\n";
+      ###rint STDERR " - working_info->size(): " . $working_info->size() . " [ < 1024 ?]\n";
+      ###rint STDERR " - doc_dir_num: " . $doc_dir_num . "\n";
+    }
   }
   while ($doc_dir_rest ne '' && ($created_directory == 0 || ($working_info->size() >= 1024 && $doc_dir_num < 2)));
@@ -940,16 +955,30 @@
 	}
 
-	my $rss_filename = &FileUtils::filenameConcatenate($output_dir,"rss-items.rdf");
-        my $rss_fh;
-	if (&FileUtils::openFileHandle($rss_filename, '>>', \$rss_fh)) {
-	    print $rss_fh "<item>\n";
-	    print $rss_fh "   <title>$dc_title</title>\n";
-	    print $rss_fh "   <link>_httpdomain__httpcollection_/document/$oid</link>\n";
-	    print $rss_fh "</item>\n";
+        my $rss_entry = "<item>\n";
+        $rss_entry   .= "   <title>$dc_title</title>\n";
+	$rss_entry   .= "   <link>_httpdomain__httpcollection_/document/$oid</link>\n";
+	$rss_entry   .= "</item>";
+
+        if (defined(&dbutil::supportsRSS) && &dbutil::supportsRSS($infodbtype))
+        {
+          my $rss_db = &dbutil::get_infodb_file_path($infodbtype, 'rss-items', $output_dir);
+          my $rss_db_fh = &dbutil::open_infodb_write_handle($infodbtype, $rss_db, 'append');
+          &dbutil::write_infodb_rawentry($infodbtype, $rss_db_fh, $oid, $rss_entry);
+          &dbutil::close_infodb_write_handle($infodbtype, $rss_db_fh);
+        }
+        else
+        {
+          my $rss_filename = &FileUtils::filenameConcatenate($output_dir,"rss-items.rdf");
+          my $rss_fh;
+          if (&FileUtils::openFileHandle($rss_filename, '>>', \$rss_fh))
+          {
+	    print $rss_fh $rss_entry . "\n";
 	    &FileUtils::closeFileHandle($rss_filename, \$rss_fh);
-	}
-	else {
+          }
+          else
+          {
 	    print STDERR "**** Failed to open $rss_filename\n$!\n";
-	}
+          }
+        }
       }
     }
