- Timestamp:
- Apr 16, 2015, 9:36:01 AM (11 years ago)
- File:
-
- 1 edited
-
trunk/pstamp/scripts/pstampparse.pl (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/pstampparse.pl
r38124 r38131 59 59 die "req_id is required" if !$req_id; 60 60 die "outdir is required" if !$outdir; 61 die "product is required" if !$product;61 # die "product is required" if !$product; 62 62 } else { 63 63 # mode eq 'list_uri' (used for parser testing) … … 95 95 # do not update the database 96 96 $no_update = 1 if $mode ne "queue_job"; 97 98 $product = 'NULL' unless $product; 99 100 # look up the default data store product. 101 my $defaultDSProduct = metadataLookupStr($ipprc->{_siteConfig}, 'PSTAMP_DATA_STORE_PRODUCT'); 102 if (!defined $defaultDSProduct) { 103 # Don't panic yet that it's not defined. 104 # exit ($PS_EXIT_CONFIG_ERROR); 105 $defaultDSProduct = ''; # set to empty string to simplify some comparisions below 106 print STDERR "Warning PSTAMP_DATA_STORE_PRODUCT not found in the site config.\n" if $product eq 'NULL'; 107 } 108 109 my $productIsDefault = 0; 110 if ($product and $defaultDSProduct) { 111 $productIsDefault = ($product eq $defaultDSProduct); 112 } 97 113 98 114 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 170 186 171 187 172 # Adjust the label for requests coming in over the web interface188 # Adjust the label for requests coming in over the web upload interface 173 189 174 190 my $label_changed = 0; … … 200 216 } 201 217 218 # product passed in is either one specific to the submitting pstampDataStore or the default 219 # "pstampresults" 220 # Here, we need to decide whether to change that based on email 221 # WE can't use label (yet) because the PSI cgi script sets it to PSI 222 # Do we ever need to use label? Is it obsolete? Check test procedures. 223 224 # XXX perhaps do this prior to label setting above after domain/user table is implemented 225 my $productForUser; 226 my $accessLevel = getUsersAccessLevel($email, \$label, \$productForUser); 227 if ($accessLevel < 0) { 228 print STDERR "Data access is forbidden.\n"; 229 insertFakeJobForRow(undef, 0, $PSTAMP_NOT_AUTHORIZED); 230 } 231 232 # if the product is the system default, set it to the product for the user@domain 233 if ($productIsDefault or $product eq 'NULL') { 234 if ($productForUser) { 235 $product = $productForUser; 236 } 237 } else { 238 if ($product eq 'NULL') { 239 $product = $defaultDSProduct; 240 } 241 } 242 if (!$product or $product eq 'NULL') { 243 my_die("No product found.\n", $PS_EXIT_CONFIG_ERROR); 244 } 202 245 203 246 { … … 219 262 } 220 263 264 if ($accessLevel < 0) { 265 exit 0; 266 } 267 221 268 if ($duplicate_req_name) { 222 269 exit 0; … … 271 318 my $num_jobs = 0; 272 319 273 my $accessLevel = getUsersAccessLevel($email, $label);274 if ($accessLevel < 0) {275 print STDERR "Data access forbidden.\n";276 insertFakeJobForRow(undef, 0, $PSTAMP_NOT_AUTHORIZED);277 exit 0;278 }279 320 280 321 foreach my $row (@$rows) { … … 534 575 # We do not adjust dates for stacks since they are not well defined enough. 535 576 # We'll need to filter them by accessLevel during the lookup 577 my $stage = $row->{IMG_TYPE}; 536 578 if ($stage ne 'stack' and adjustDateCuts($row, \$mjd_max)) { 537 579 # if lower limit was supplied by user we can leave the value alone … … 1200 1242 sub getUsersAccessLevel { 1201 1243 my $email = shift; 1202 my $label = shift; 1244 my $r_label = shift; 1245 my $r_product = shift; 1246 1247 my $label = $$r_label; 1203 1248 1204 1249 my $level = -1; … … 1217 1262 # we've got an email check the domain 1218 1263 my ($user, $domain) = split '@', $email; 1219 if ($domain) { 1264 unless ($user and $domain) { 1265 print STDERR "Error $email is not an acceptable email adddress.\n"; 1266 } else { 1220 1267 $domain = lc($domain); 1221 1268 if ($domain eq 'ifa.hawaii.edu' or $domain eq 'qub.ac.uk') { 1222 $level = 0;1269 $level = 2; 1223 1270 } else { 1224 1271 # XXX check for special users … … 1226 1273 $level = 1; 1227 1274 } 1228 } else { 1229 print STDERR "Error: $email is not a valid email address\n"; 1230 } 1275 1276 # 1277 if ($user eq 'bills' and $domain eq 'ifa.hawaii.edu') { 1278 $$r_product = 'bills-results'; 1279 } 1280 } 1281 1231 1282 } 1232 1283
Note:
See TracChangeset
for help on using the changeset viewer.
