Changeset 13092 for trunk/Nebulous-Server/lib/Nebulous/Server.pm
- Timestamp:
- Apr 30, 2007, 4:52:04 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/Nebulous-Server/lib/Nebulous/Server.pm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous-Server/lib/Nebulous/Server.pm
r13087 r13092 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: Server.pm,v 1.2 7 2007-05-01 02:00:07jhoblitt Exp $3 # $Id: Server.pm,v 1.28 2007-05-01 02:52:04 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server; … … 123 123 my $self = shift; 124 124 125 my ( $key, $class, $volume, $comment ) = validate_pos( @_, 126 { 127 type => SCALAR, 128 }, 129 { 130 type => SCALAR, 131 callbacks => { 132 'is + integer' => sub { $_[0] =~ /^\d+$/ }, 133 # check that the class requested is valid 134 'is valid class id' => sub { $self->_is_valid_class_id( $_[0] ) }, 135 }, 136 default => 0, 125 my ($key, $volume) = validate_pos(@_, 126 { 127 type => SCALAR, 137 128 }, 138 129 { … … 144 135 optional => 1, 145 136 }, 146 {147 type => SCALAR,148 callbacks => {149 # check that the comment isn't too long150 'comment length' => sub { length $_[0] < 256 },151 },152 optional => 1,153 },154 137 ); 155 138 … … 185 168 # create storage_object_attr 186 169 my $query = $db->prepare_cached( $sql->new_object_attr ); 187 $query->execute( $object_id , $class, $comment);170 $query->execute( $object_id ); 188 171 } 189 172 … … 1070 1053 } 1071 1054 1072 sub _is_valid_class_id {1073 my ($self, $class_id) = @_;1074 1075 my $log = $self->log;1076 my $sql = $self->sql;1077 my $db = $self->db;1078 1079 my $class;1080 eval {1081 my $query = $db->prepare_cached( $sql->get_class_by_id );1082 $query->execute( $class_id );1083 ( $class ) = $query->fetchrow_array;1084 1085 $query->finish;1086 };1087 if ( $@ ) {1088 $db->rollback;1089 $log->logdie( "database error: $@" );1090 }1091 1092 return ( defined $class ) ? 1 : undef;1093 }1094 1095 1055 sub _is_valid_volume_name { 1096 1056 my ($self, $vol_name) = @_;
Note:
See TracChangeset
for help on using the changeset viewer.
