Changeset 28175

Show
Ignore:
Timestamp:
28.08.2013 18:01:35 (6 years ago)
Author:
ak19
Message:

Splitting resolve_collection_dir into two functions, one of which resolves and gets the collect_dir, since I wish to reuse the latter

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/util.pm

    r28174 r28175  
    12151215    my ($colgroup, $collection) = &util::get_collection_parts($qualified_collection);    
    12161216     
    1217     if (defined $collect_dir && $collect_dir) { # ensure not empty string either 
    1218         return &FileUtils::filenameConcatenate($collect_dir,$colgroup, $collection); 
    1219     } 
    1220     elsif (defined($ENV{'GSDLCOLLECTDIR'})) { # does GS3 ever have GSDLCOLLECTDIR defined? Is it the parent of sites? 
    1221         if (defined $site) { 
    1222         return &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'},$colgroup, $collection); # assume GSDLCOLLECTDIR is the "collect" folder? 
    1223         #return &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'},"sites",$site,"collect",$colgroup, $collection); 
    1224         } 
    1225         else { 
    1226         return &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'},$colgroup, $collection); 
    1227         } 
    1228     } 
    1229     else { 
    1230         if (defined $site) { 
    1231             return &FileUtils::filenameConcatenate($ENV{'GSDL3HOME'},"sites",$site,"collect",$colgroup, $collection); 
    1232         } 
    1233         else { 
    1234             return &FileUtils::filenameConcatenate($ENV{'GSDLHOME'},"collect",$colgroup, $collection); 
    1235         } 
    1236     } 
     1217    if (!defined $collect_dir || !$collect_dir) { # if undefined or empty string 
     1218        $collect_dir = &util::get_working_collect_dir($site); 
     1219    } 
     1220 
     1221    return &FileUtils::filenameConcatenate($collect_dir,$colgroup,$collection); 
     1222} 
     1223 
     1224# work out the full path to "collect" of this greenstone 2/3 installation 
     1225sub get_working_collect_dir { 
     1226    my ($site) = @_; 
     1227     
     1228    if (defined $ENV{'GSDLCOLLECTDIR'}) { # a predefined collect dir exists 
     1229    return $ENV{'GSDLCOLLECTDIR'}; 
     1230    } 
     1231     
     1232    elsif (defined $site && $site) { # site non-empty, so get default collect dir for GS3 
     1233    if defined $ENV{'GSDL3HOME'} { 
     1234        return &FileUtils::filenameConcatenate($ENV{'GSDL3HOME'},"sites",$site,"collect"); 
     1235    } else { 
     1236        return &FileUtils::filenameConcatenate($ENV{'GSDL3SRCHOME'},"web","sites",$site,"collect"); 
     1237    } 
     1238    } 
     1239     
     1240    else { # get default collect dir for GS2 
     1241    return &FileUtils::filenameConcatenate($ENV{'GSDLHOME'},"collect"); 
     1242    } 
    12371243} 
    12381244