IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5490 for trunk/Nebulous/lib


Ignore:
Timestamp:
Nov 8, 2005, 3:31:07 PM (21 years ago)
Author:
jhoblitt
Message:

change create_object to verify that it's class param is valid

Location:
trunk/Nebulous/lib/Nebulous
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous/lib/Nebulous/Server.pm

    r5487 r5490  
    11# Copyright (c) 2004  Joshua Hoblitt
    22#
    3 # $Id: Server.pm,v 1.12 2005-11-09 00:48:24 jhoblitt Exp $
     3# $Id: Server.pm,v 1.13 2005-11-09 01:31:07 jhoblitt Exp $
    44
    55package Nebulous::Server;
     
    1717use Log::Log4perl;
    1818use Params::Validate qw( validate_pos SCALAR );
    19 
    20 my %class = (
    21     raw => 1,
    22 );
    2319
    2420my $log;
     
    9995
    10096    # check that the comment isn't too long
     97    # check that the volume requested is valid
     98
    10199    # check that the class requested is valid
    102     # check that the volume requested is valid
     100    if ( $class ) {
     101        my $class_id;
     102        eval {
     103            my $query = $db->prepare_cached( $sql->get_class );
     104            $query->execute( $class );
     105            ( $class_id ) = $query->fetchrow_array;
     106
     107            $query->finish;
     108        };
     109        if ( $@ ) {
     110            $db->rollback;
     111            $log->logdie( "database error: $@" );
     112        }
     113
     114        unless ( $class_id ) {
     115            $log->logdie( "Invalid class ID: $class" );
     116        }
     117    }
    103118
    104119    my $uri;
  • trunk/Nebulous/lib/Nebulous/Server/SQL.pm

    r5489 r5490  
    11# Copyright (c) 2004  Joshua Hoblitt
    22#
    3 # $Id: SQL.pm,v 1.13 2005-11-09 00:59:20 jhoblitt Exp $
     3# $Id: SQL.pm,v 1.14 2005-11-09 01:31:07 jhoblitt Exp $
    44
    55package Nebulous::Server::SQL;
     
    123123        INSERT INTO volume (name, uri)
    124124        VALUES (?, ?)
     125    },
     126    get_class => qq{
     127        SELECT class_id, priority, comment
     128        FROM class
     129        WHERE class_id = ?
    125130    },
    126131);
Note: See TracChangeset for help on using the changeset viewer.