Show
Ignore:
Timestamp:
14.03.2017 20:10:07 (3 years ago)
Author:
ak19
Message:

Found servercontrol::get_library_url() largely duplicated in util.pm as get_fullgreenstone_url_prefix(). Merging the two functions. Tested that solr-jdbm-demo collection still rebuilds (with and without tomcat running, and with and without port change between sessions).

Location:
main/trunk/greenstone2/perllib
Files:
2 modified

Legend:

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

    r31516 r31518  
    365365 
    366366sub get_library_URL { 
     367    my $self = shift(@_); 
     368     
     369    # For web servers that are external to a Greenstone installation,  
     370    # the user can pass in their web server's library URL. 
     371    if($self->{'library_url'}) { 
     372    return $self->{'library_url'}; 
     373    } 
     374     
     375    # For web servers included with GS (like tomcat for GS3 and server.exe  
     376    # and apache for GS2), we work out the library URL: 
     377    my ($gs_mode, $lib_name); # gs_mode can be gs3 or gs2, lib_name is the custom servlet name 
     378    $gs_mode = $self->{'gs_mode'}; 
     379    $lib_name = $self->{'library_name'}; 
     380     
     381    # If we get here, we are dealing with a server included with GS. 
     382    # For GS3, we ask ant for the library URL. 
     383    # For GS2, we derive the URL from the llssite.cfg file. 
     384 
     385    my $url = &util::get_full_greenstone_url_prefix($gs_mode, $lib_name); # found largely identical method copied 
     386            # into util. Don't want duplicates, so calling that from here. 
     387     
     388    # either the url is still undef or it is now set 
     389    #print STDERR "\n@@@@@ final URL:|$url|\n" if $url;      
     390    #print STDERR "\n@@@@@ URL still undef\n" if !$url; 
     391     
     392    if (defined $url) { 
     393        $self->{'library_url'} = $url; 
     394    } 
     395 
     396    return $url; 
     397} 
     398 
     399sub OLD_get_library_URL { 
    367400    my $self = shift(@_);     
    368401     
  • main/trunk/greenstone2/perllib/util.pm

    r31517 r31518  
    12271227sub get_full_greenstone_url_prefix 
    12281228{    
     1229    my ($gs_mode, $lib_name) = @_; 
     1230     
    12291231    # if already set on a previous occasion, just return that 
    12301232    # (Don't want to keep repeating this: cost of re-opening and scanning files.) 
    12311233    return $ENV{'FULL_GREENSTONE_URL_PREFIX'} if($ENV{'FULL_GREENSTONE_URL_PREFIX'}); 
    12321234 
    1233     my $gs_mode = ($ENV{'GSDL3SRCHOME'}) ? "gs3" : "gs2"; 
     1235    # set gs_mode if it was not passed in (servercontrol.pm would pass it in, any other callers won't) 
     1236    $gs_mode = ($ENV{'GSDL3SRCHOME'}) ? "gs3" : "gs2" unless defined $gs_mode; 
    12341237     
    12351238    my $url = undef;     
     
    13281331        } 
    13291332        close(PIN); 
     1333         
     1334        if (defined $lib_name) { # url won't be undef now 
     1335            # replace the servlet_name portion of the url found, with the given library_name 
     1336            $url =~ s@/[^/]*$@/$lib_name@; 
     1337        } 
    13301338    } else { 
    13311339        print STDERR "util::get_full_greenstone_url_prefix() failed to run $perl_command to work out library URL for $gs_mode\n";