Commit 5ef66735 authored by Gary Wong's avatar Gary Wong

Fix a bunch of syntax errors.

parent e9b0636e
......@@ -89,65 +89,65 @@ sub Map($)
return GeniResponse->Create( GENIRESPONSE_UNSUPPORTED )
unless $HAVE_XERCES eq "yes";
my $multipleads = 0;
my @adfiles;
my @adfilenames;
my ( $merged_adfile, $merged_adfilename ) = tempfile();
my $mergeCmdString = "$ADVT_MERGE $merged_adfilename";
# If the input is an array reference, multiple advertisements have
# been passed and they need to be merged
if (ref($ad) eq "ARRAY") {
$multipleads = 1;
for(my $i = 0; $i < (@{$ad}); $i++) {
my $advt = $ad[$i];
# If the ad is Binary typed (and therefore base64 encoded),
# assume it is compressed.
if( Scalar::Util::blessed( $advt )
&& $advt->isa( "Frontier::RPC2::Base64" ) ) {
$advt = uncompress( decode_base64( $advt->value ) );
}
( $adfiles[$i], $adfilenames[$i] ) = tempfile();
return GeniResponse->Create( GENIRESPONSE_ERROR, undef,
"Could not store advertisement" )
unless defined $adfiles[$i];
print $adfiles[$i] $advt;
close $adfiles[$i];
$mergeCmdString .= " $adfilenames[$i]";
}
my $result = system($mergeCmdString);
return GeniResponse->Create( GENIRESPONSE_ERROR, undef,
"Could not merge advertisements" )
unless $result == 0;
my $multipleads = 0;
my @adfiles;
my @adfilenames;
my ( $merged_adfile, $merged_adfilename ) = tempfile();
my $mergeCmdString = "$ADVT_MERGE $merged_adfilename";
# If the input is an array reference, multiple advertisements have
# been passed and they need to be merged
if (ref($ad) eq "ARRAY") {
$multipleads = 1;
for(my $i = 0; $i < (@{$ad}); $i++) {
my $advt = $$ad[$i];
# If the ad is Binary typed (and therefore base64 encoded),
# assume it is compressed.
if( Scalar::Util::blessed( $advt )
&& $advt->isa( "Frontier::RPC2::Base64" ) ) {
$advt = uncompress( decode_base64( $advt->value ) );
}
( $adfiles[$i], $adfilenames[$i] ) = tempfile();
return GeniResponse->Create( GENIRESPONSE_ERROR, undef,
"Could not store advertisement" )
unless defined $adfiles[$i];
print { $adfiles[$i] } $advt;
close $adfiles[$i];
$mergeCmdString .= " $adfilenames[$i]";
}
# It is not a reference and it must be a single file that was passed
elsif (!ref($ad)) {
# If the ad is Binary typed (and therefore base64 encoded), assume
# it is compressed.
if( Scalar::Util::blessed( $ad )
&& $ad->isa( "Frontier::RPC2::Base64" ) ) {
$ad = uncompress( decode_base64( $ad->value ) );
}
return GeniResponse->Create( GENIRESPONSE_ERROR, undef,
"Could not store advertisement" )
unless defined $merged_adfile;
print $merged_adfile $ad;
close $merged_adfile;
my $result = system($mergeCmdString);
return GeniResponse->Create( GENIRESPONSE_ERROR, undef,
"Could not merge advertisements" )
unless $result == 0;
}
# It is not a reference and it must be a single file that was passed
elsif (!ref($ad)) {
# If the ad is Binary typed (and therefore base64 encoded), assume
# it is compressed.
if( Scalar::Util::blessed( $ad )
&& $ad->isa( "Frontier::RPC2::Base64" ) ) {
$ad = uncompress( decode_base64( $ad->value ) );
}
#
# Use assign in xml mode to spit back an xml file.
#
my ( $reqfile, $reqfilename ) = tempfile();
return GeniResponse->Create( GENIRESPONSE_ERROR, undef,
"Could not store request" )
"Could not store advertisement" )
unless defined $merged_adfile;
print $merged_adfile $ad;
close $merged_adfile;
}
#
# Use assign in xml mode to spit back an xml file.
#
my ( $reqfile, $reqfilename ) = tempfile();
return GeniResponse->Create( GENIRESPONSE_ERROR, undef,
"Could not store request" )
unless defined $reqfile;
print $reqfile $req;
close $reqfile;
print $reqfile $req;
close $reqfile;
open( ASSIGN, "$ASSIGN -P -q $merged_adfilename -w $reqfilename 2>&1 |" )
or return GeniResponse->Create( GENIRESPONSE_ERROR, undef,
......@@ -159,11 +159,12 @@ sub Map($)
}
close ASSIGN;
if ($multipleads == 1) {
foreach $adfilename (@adfilenames) {
unlink $adfilename;
}
if ($multipleads == 1) {
my $adfilename;
foreach $adfilename (@adfilenames) {
unlink $adfilename;
}
}
unlink $merged_adfilename;
unlink $reqfilename;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment