Changeset 27858
- Timestamp:
- 2013-07-15T19:51:31+12:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-extensions/solr/trunk/src/perllib/solrserver.pm
r27847 r27858 209 209 } 210 210 211 sub filtered_copy 212 { 213 my $self = shift @_; 214 my ($src_file,$dst_file,$re_substitutions) = @_; 215 216 my $sep = shift @_ || "/"; 217 my $flags = shift @_ || "g"; 218 219 # $re_substitutions is a hashmap of the form: [re_key] => subst_str 220 221 my $content = ""; 222 223 if (open(FIN,'<:utf8',$src_file)) { 224 225 my $line; 226 while (defined($line=<FIN>)) { 227 $content .= $line; 228 } 229 } 230 231 close(FIN); 232 233 # perform RE string substitutions 234 foreach my $re_key (keys %$re_substitutions) { 235 236 my $subst_str = $re_substitutions->{$re_key}; 237 238 # Perform substitution of the form: 239 # $content =~ s/$re_key/$subst_str/g; 240 # but allow allow separator char (default '/') 241 # and flags (default 'g') to be parameterized 242 243 my $eval_str = "\$content =~ s$sep$re_key$sep$subst_str$sep$flags"; 244 245 eval { 246 $eval_str; 247 }; 248 if ($@) { 249 print STDERR "Warning: failed to evaluate\n $eval_str\n$@\n"; 250 } 251 252 } 253 254 if (open(FOUT, '>:utf8', $dst_file)) { 255 print FOUT $content; 256 close(FOUT); 257 } 258 else { 259 print STDERR "Error: Failed to open file '$dst_file' for writing.\n$!\n"; 260 } 261 } 262 263 sub solr_xml_to_solr_xml_in 264 { 265 my $self = shift @_; 266 267 my $gsdl3home = $ENV{'GSDL3HOME'}; 268 my $web_solr_ext_dir = &util::filename_cat($gsdl3home, "ext", "solr"); 269 my $web_solrxml_in = &util::filename_cat($web_solr_ext_dir, "solr.xml.in"); 270 my $web_solrxml = &util::filename_cat($web_solr_ext_dir, "solr.xml"); 271 272 my $replacement_map = { "$gsdl3home" => "\\\@gsdl3home\\\@" }; 273 274 $self->filtered_copy($web_solrxml,$web_solrxml_in,$replacement_map, "^", "g"); 275 } 276 277 278 sub solr_xml_in_to_solr_xml 279 { 280 my $self = shift @_; 281 282 my $gsdl3home = $ENV{'GSDL3HOME'}; 283 my $web_solr_ext_dir = &util::filename_cat($gsdl3home, "ext", "solr"); 284 my $web_solrxml_in = &util::filename_cat($web_solr_ext_dir, "solr.xml.in"); 285 my $web_solrxml = &util::filename_cat($web_solr_ext_dir, "solr.xml"); 286 287 my $replacement_map = { "\\\@gsdl3home\\\@" => "$gsdl3home" }; 288 289 $self->filtered_copy($web_solrxml_in,$web_solrxml,$replacement_map, "^", "g"); 290 } 291 292 211 293 # Some of the Solr CoreAdmin API calls available. 212 294 # See http://wiki.apache.org/solr/CoreAdmin … … 219 301 220 302 $self->_admin_service($cgi_get_args); 303 304 $self->solr_xml_to_solr_xml_in(); 221 305 } 222 306 … … 229 313 230 314 $self->_admin_service($cgi_get_args); 315 316 $self->solr_xml_to_solr_xml_in(); 231 317 } 232 318 … … 239 325 240 326 $self->_admin_service($cgi_get_args); 327 328 $self->solr_xml_to_solr_xml_in(); 241 329 } 242 330 … … 251 339 252 340 $self->_admin_service($cgi_get_args); 341 342 $self->solr_xml_to_solr_xml_in(); 253 343 } 254 344 … … 275 365 276 366 $self->_admin_service($cgi_get_args); 367 368 $self->solr_xml_to_solr_xml_in(); 277 369 } 278 370 … … 289 381 290 382 $self->_admin_service($cgi_get_args); 383 384 $self->solr_xml_to_solr_xml_in(); 291 385 } 292 386 … … 295 389 my $self = shift @_; 296 390 297 my $ext_solrxml = &util::filename_cat($ENV{'GEXT_SOLR'}, "solr.xml ");298 my $web_solrxml = &util::filename_cat($ENV{'GSDL3HOME'}, "ext", "solr", "solr.xml ");391 my $ext_solrxml = &util::filename_cat($ENV{'GEXT_SOLR'}, "solr.xml.in"); 392 my $web_solrxml = &util::filename_cat($ENV{'GSDL3HOME'}, "ext", "solr", "solr.xml.in"); 299 393 300 394 #print STDERR "@@@@ Copying $ext_solrxml to $web_solrxml...\n"; 301 395 302 396 &FileUtils::copyFiles($ext_solrxml, $web_solrxml); 397 398 $self->solr_xml_in_to_solr_xml(); 303 399 } 304 400
Note:
See TracChangeset
for help on using the changeset viewer.