Show
Ignore:
Timestamp:
10.05.2016 16:39:20 (4 years ago)
Author:
ak19
Message:

1. get_library_URL() called internal to servercontrol.pm when using servercontrol in activate.pl too. 2. More tidying up: removed lots of variables no longer in use.

Location:
main/trunk/greenstone2
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/bin/script/activate.pl

    r30523 r30524  
    113113     
    114114    print STDERR "\n"; 
    115     print STDERR "Usage: $progname [-collectdir c -builddir b -indexdir i -site s -skipactivation -removeold -keepold -verbosity v\n"; 
     115    print STDERR "Usage: $progname [-collectdir c -builddir b -indexdir i -site s -skipactivation -removeold -keepold -incremental -verbosity v\n"; 
    116116    print STDERR "\t-library_url URL -library_name n] <[colgroup/]collection>\n"; 
    117117    print STDERR "\n"; 
     
    247247     
    248248    # 1. Get library URL 
    249      
    250     # For web servers that are external to a Greenstone installation,  
    251     # the user can pass in their web server's library URL. 
    252     # For web servers included with GS (like tomcat for GS3 and server.exe  
    253     # and apache for GS2), we work out the library URL: 
    254     if(!$library_url) {  
    255     $library_url = $gsserver->get_library_URL(); # returns undef if no server is running 
    256     } 
    257      
    258     # CollectionManager's installCollection phase in GLI 
    259     # 2. Ping the library URL, and if it's a persistent server and running, release the collection     
    260     if($library_url && !$skipactivation) { # undef if no valid server URL    
    261     $gsserver->do_deactivate();  
    262     } 
     249    # CollectionManager's installCollection phase in GLI: 
     250    # 2. Ping the library URL, and if it's a persistent server and running, release the collection    
     251    $gsserver->do_deactivate() unless $skipactivation;     
    263252 
    264253    # 2b. If we're working with a solr collection, then start up the solrserver now. 
     
    386375 
    387376     
    388     # 4. Ping the library URL, and if it's a persistent server and running, activate the collection again    
     377    # 4. Ping the library URL, and if it's a persistent server and running, activate the collection again 
    389378     
    390379    # Check for success: if building does not exist OR is empty OR if building is index (in which case there was no move)    
    391380    if($build_dir eq $index_dir || !&FileUtils::directoryExists($build_dir) || &FileUtils::isDirectoryEmpty($build_dir)) { 
    392381     
    393     if($library_url && !$skipactivation) { # undef if no valid server URL 
    394         $gsserver->do_activate(); 
    395     } 
     382    $gsserver->do_activate() unless $skipactivation; 
     383     
    396384    } else { # installcollection failed      
    397385    #CollectionManager.Preview_Ready_Failed 
  • main/trunk/greenstone2/perllib/servercontrol.pm

    r30523 r30524  
    5050  my ($qualified_collection, $site, $verbosity, $build_dir, $index_dir, $collect_dir, $library_url, $library_name) = @_; 
    5151 
     52  # library_url: to be specified on the cmdline if not using a GS-included web server 
     53  # the GSDL_LIBRARY_URL env var is useful when running cmdline buildcol.pl in the linux package manager versions of GS3 
     54 
    5255  my $self = {'build_dir' => $build_dir, 
    5356              'index_dir' => $index_dir, 
     
    113116sub config { 
    114117    my $self = shift(@_); 
    115     my ($command, $check_message_against_regex, $site, $expected_error_code, $silent) = @_; 
    116  
    117     my ($library_url); 
    118     $library_url = $self->{'library_url'}; 
    119     #$site = $self->{'site'}; 
     118    my ($command, $check_message_against_regex, $expected_error_code, $silent) = @_; 
     119 
     120    my $library_url = $self->get_library_URL(); #$self->{'library_url'}; 
    120121 
    121122 
     
    192193    my $self = shift(@_); 
    193194 
    194     my ($library_url, $gs_mode, $qualified_collection, $site); 
    195     $library_url = $self->{'library_url'}; 
    196     $gs_mode = $self->{'gs_mode'}; 
    197     $qualified_collection = $self->{'qualified_collection'}; 
    198     $site = $self->{'site'}; 
     195    my $gs_mode = $self->{'gs_mode'}; 
     196    my $qualified_collection = $self->{'qualified_collection'}; 
    199197     
    200198    if($gs_mode eq "gs2") { 
     
    206204    my $DEACTIVATE_COMMAND = "?a=s&sa=d&st=collection&sn="; 
    207205    my $check_message_against_regex = "collection: $qualified_collection deactivated"; 
    208     $self->config($DEACTIVATE_COMMAND.$qualified_collection, $check_message_against_regex, $site); 
     206    $self->config($DEACTIVATE_COMMAND.$qualified_collection, $check_message_against_regex); 
    209207    }    
    210208} 
     
    213211    my $self = shift(@_); 
    214212 
    215     my ($library_url, $gs_mode, $qualified_collection, $site); 
    216     $library_url = $self->{'library_url'}; 
    217     $gs_mode = $self->{'gs_mode'}; 
    218     $qualified_collection = $self->{'qualified_collection'}; 
    219     $site = $self->{'site'}; 
     213    my $gs_mode = $self->{'gs_mode'}; 
     214    my $qualified_collection = $self->{'qualified_collection'}; 
    220215 
    221216    if($gs_mode eq "gs2") { 
     
    227222    my $ACTIVATE_COMMAND = "?a=s&sa=a&st=collection&sn="; 
    228223    my $check_message_against_regex = "collection: $qualified_collection activated"; 
    229     $self->config($ACTIVATE_COMMAND.$qualified_collection, $check_message_against_regex, $site); 
     224    $self->config($ACTIVATE_COMMAND.$qualified_collection, $check_message_against_regex); 
    230225    }    
    231226} 
     
    235230    my $command = shift(@_); 
    236231    my $silent = shift(@_); 
    237  
    238     my ($library_url, $gs_mode, $site); 
    239     $library_url = $self->{'library_url'};      
    240     $gs_mode = $self->{'gs_mode'}; 
    241     $site = $self->{'site'}; 
    242232     
    243233    # If the GS server is not running, we *expect* to see a "500" status code. 
     
    250240    $self->print_msg("*** COMMAND WAS: |$command|***\n", 4); 
    251241     
    252     return $self->config($command, $check_responsemsg_against_regex, $site, $expected_error_code, $silent); 
     242    return $self->config($command, $check_responsemsg_against_regex, $expected_error_code, $silent); 
    253243} 
    254244 
     
    257247    my $self = shift(@_); 
    258248 
    259     my ($library_url, $gs_mode, $site); 
    260     $library_url = $self->{'library_url'}; 
    261     $gs_mode = $self->{'gs_mode'}; 
    262     $site = $self->{'site'}; 
     249    my $gs_mode = $self->{'gs_mode'}; 
    263250 
    264251    my $command = ""; 
     
    278265    my $silent = shift(@_); 
    279266 
    280     my ($library_url, $gs_mode, $qualified_collection, $site); 
    281     $library_url = $self->{'library_url'}; 
    282     $gs_mode = $self->{'gs_mode'}; 
    283     $qualified_collection = $self->{'qualified_collection'}; 
    284     $site = $self->{'site'}; 
    285     #$silent = $self->{'silent'}; 
     267    my $gs_mode = $self->{'gs_mode'}; 
     268    my $qualified_collection = $self->{'qualified_collection'}; 
    286269 
    287270    my $command = ""; 
     
    299282sub is_persistent { 
    300283    my $self = shift(@_); 
    301  
    302     my ($library_url, $gs_mode); 
    303     $library_url = $self->{'library_url'}; 
    304     $gs_mode = $self->{'gs_mode'}; 
    305      
    306     if($gs_mode eq "gs3") { # GS3 server is always persistent 
     284     
     285    if($self->{'gs_mode'} eq "gs3") { # GS3 server is always persistent 
    307286    return 1; 
    308287    } 
     
    450429    my $self = shift(@_); 
    451430 
    452     my($is_persistent_server, $library_url, $gs_mode, $site, $qualified_collection); 
    453     $is_persistent_server = $self->{'is_persistent_server'}; 
    454     $library_url = $self->get_library_URL(); #may not yet be set, so can't do $self->{'library_url'}; 
    455     $site = $self->{'site'}; 
    456     $gs_mode = $self->{'gs_mode'}; 
    457     $qualified_collection = $self->{'qualified_collection'}; 
    458  
     431    # 1. Get library URL 
     432     
     433    # For web servers that are external to a Greenstone installation,  
     434    # the user can pass in their web server's library URL. 
     435    # For web servers included with GS (like tomcat for GS3 and server.exe  
     436    # and apache for GS2), we work out the library URL: 
     437 
     438    # Can't do $self->{'library_url'}, because it may not yet be set 
     439    my $library_url = $self->get_library_URL(); # returns undef if no server is running 
     440 
     441    if(!defined $library_url) { # undef if no valid server URL 
     442    return; # can't do any deactivation without a running GS server 
     443    } 
     444 
     445    my $is_persistent_server = $self->{'is_persistent_server'}; 
     446    my $qualified_collection = $self->{'qualified_collection'}; 
     447 
     448    # CollectionManager's installCollection phase in GLI 
     449    # 2. Ping the library URL, and if it's a persistent server and running, release the collection 
    459450 
    460451    $self->print_msg("Pinging $library_url\n");      
     
    498489    my $self = shift @_; 
    499490 
    500     my($is_persistent_server, $library_url, $gs_mode, $site, $qualified_collection); 
    501     $is_persistent_server = $self->{'is_persistent_server'}; 
    502     $library_url = $self->get_library_URL(); #may not yet be set, so can't do $self->{'library_url'}; 
    503     $site = $self->{'site'}; 
    504     $gs_mode = $self->{'gs_mode'}; 
    505     $qualified_collection = $self->{'qualified_collection'}; 
     491    my $library_url = $self->get_library_URL(); # Can't do $self->{'library_url'}; as it may not be set yet 
     492 
     493    if(!defined $library_url) { # undef if no valid server URL 
     494    return; # nothing to activate if there's no running server 
     495    } 
     496 
     497    my $is_persistent_server = $self->{'is_persistent_server'}; 
     498    my $qualified_collection = $self->{'qualified_collection'}; 
    506499 
    507500    $self->print_msg("Pinging $library_url\n");