IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 20, 2015, 2:39:23 PM (11 years ago)
Author:
bills
Message:

get date cuts for given accessLevel from the database.
Ready to deploy accessLevel control to production.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pstamp/scripts/pstampparse.pl

    r38133 r38160  
    3333my $dest_requires_magic;
    3434my $dump_params = 0;
     35my $new_email;
     36
     37my %accessLevelCache;
    3538
    3639# set this to true to disable update processing
     
    4346    'product=s' =>  \$product,
    4447    'label=s'   =>  \$label,
     48    'new_email=s' => \$new_email,
    4549    'mode=s'    =>  \$mode,
    4650    'need_magic'=>  \$dest_requires_magic,
     
    142146    print STDERR "Note that EMAIL will not be optional\n";
    143147
     148    # if need be we can hack Peter Veres' email in here if label = 'WEB.UP' and req_name like 'Peter_Veres%'
     149
    144150} elsif (!$email) {
    145151    my_die("ERROR: Required parameter EMAIL not found in request file header.\n", $PSTAMP_INVALID_REQUEST)
    146152}
     153
     154
    147155   
    148156
     
    158166    my_die("email not supplied in version $extver request file $request_file_name\n", $PSTAMP_INVALID_REQUEST)
    159167        unless $email;
    160 
    161     # XXX check for "valid" $email
    162168} else {
    163169    # for version 1 file the action is process and email is not used
     
    167173
    168174print "Request Header Keywords EXTVER: $extver REQ_NAME: $req_name ACTION: $action EMAIL: $email\n";
     175
     176if ($new_email) {
     177    # this is primarily for ease in testing
     178    print "Setting email to command line provided value $new_email\n";
     179    $email = $new_email
     180}
    169181
    170182# check for duplicate request name
     
    239251
    240252# if the request came through the upload channel, change it to the user's specific label
    241 # if any is known.
     253# if any is known. Do we want to do this for any other channels?
    242254if ($label and $label eq 'WEB.UP') {
    243255    if ($labelForUser) {
     
    749761
    750762            if ($mjd > $mjd_max) {
    751                 print STDERR "User is not authorized for stamps from this exposure.\n";
     763                print "User is not authorized for stamps from this exposure exp_id $exp_id.\n";
     764                print STDERR "User is not authorized for stamps from this exposure exp_id $exp_id.\n";
    752765                insertFakeJobForRow($row, $job_num, $PSTAMP_NOT_AUTHORIZED, $exp_id);
    753766                return 1;
     
    13431356    my $adjusted = 0;
    13441357
    1345     my $MJD_PS1_BEGIN = 54922;    # 2009-04-01
    1346     my $MJD_PS1_END   = 57082;    # 2015-03-01
    1347 
    1348     if ($row->{accessLevel} == 1) {
    1349         # User has access to PS1 data only
    1350         my $mjd_max_user = $row->{MJD_MAX};
    1351         if (!$mjd_max_user or $mjd_max_user > $MJD_PS1_END) {
    1352             $$r_mjd_max = $MJD_PS1_END;
     1358    my $accessLevel = $row->{accessLevel};
     1359    my $project = $row->{PROJECT};
     1360    my $mjd_max_user = $row->{MJD_MAX};
     1361
     1362    my $key = "$project.$accessLevel";
     1363
     1364    my $levelInfo = $accessLevelCache{$key};
     1365
     1366    if (!$levelInfo) {
     1367        my $cmd = "$pstamptool -listaccesslevel -accessLevel $accessLevel -project_name $project";
     1368        my $results = runToolAndParse($cmd, $verbose);
     1369        if (!$results or !$results->[0]) {
     1370            my_die("failed to find accessLevel info for project: $project level: $accessLevel\n", $PS_EXIT_CONFIG_ERROR);
     1371        }
     1372        $levelInfo = $results->[0];
     1373        $accessLevelCache{$key} = $levelInfo;
     1374    }
     1375
     1376    my $mjd_max_thisLevel = $levelInfo->{mjd_max};
     1377    if ($mjd_max_thisLevel)  {
     1378        # This project has a limit for this level
     1379        # adjust the user supplied limit unless it is less than the maximum
     1380
     1381        if (!$mjd_max_user or ($mjd_max_user > $mjd_max_thisLevel)) {
     1382            $$r_mjd_max = $mjd_max_thisLevel;
    13531383            $adjusted = 1;
    13541384        }
    13551385    }
     1386
    13561387    return $adjusted;
    13571388}
Note: See TracChangeset for help on using the changeset viewer.