Index: /trunk/Nebulous-Server/lib/Nebulous/Server.pm
===================================================================
--- /trunk/Nebulous-Server/lib/Nebulous/Server.pm	(revision 13202)
+++ /trunk/Nebulous-Server/lib/Nebulous/Server.pm	(revision 13203)
@@ -1,5 +1,5 @@
 # Copyright (c) 2004  Joshua Hoblitt
 #
-# $Id: Server.pm,v 1.33 2007-05-03 03:21:28 jhoblitt Exp $
+# $Id: Server.pm,v 1.34 2007-05-03 22:10:13 jhoblitt Exp $
 
 package Nebulous::Server;
@@ -244,7 +244,14 @@
         {
             type        => SCALAR,
-        },
-        {
-            type        => SCALAR,
+            callbacks   => {
+                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
+            },
+        },
+        # make sure the "newkey" doesn't already exist
+        {
+            type        => SCALAR,
+            callbacks   => {
+                'is not valid object key' => sub { not $self->_is_valid_object_key($_[0]) },
+            },
         },
     );
@@ -382,5 +389,6 @@
 }
 
-sub lock_object {
+sub lock_object
+{
     my $self = shift;
 
@@ -388,4 +396,7 @@
         {
             type        => SCALAR,
+            callbacks   => {
+                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
+            },
         },
         {
@@ -501,5 +512,6 @@
 }
 
-sub unlock_object {
+sub unlock_object
+{
     my $self = shift;
 
@@ -507,4 +519,7 @@
         {
             type        => SCALAR,
+            callbacks   => {
+                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
+            },
         },
         {
@@ -635,4 +650,7 @@
         {
             type        => SCALAR,
+            callbacks   => {
+                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
+            },
         },
         {
@@ -706,4 +724,7 @@
         {
             type        => SCALAR,
+            callbacks   => {
+                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
+            },
         },
         {
@@ -751,4 +772,7 @@
         {
             type        => SCALAR,
+            callbacks   => {
+                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
+            },
         },
     );
@@ -789,4 +813,7 @@
         {
             type        => SCALAR,
+            callbacks   => {
+                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
+            },
         },
         {
@@ -831,5 +858,6 @@
 
 
-sub find_objects {
+sub find_objects
+{
     my $self = shift;
 
@@ -870,5 +898,6 @@
 
 
-sub find_instances {
+sub find_instances
+{
     my $self = shift;
 
@@ -939,5 +968,7 @@
 }
 
-sub delete_instance {
+
+sub delete_instance
+{
     my $self = shift;
 
@@ -983,5 +1014,6 @@
             my $rows = $query->execute( $uri );
             
-            # if we affected something other then one row something very bad has happened
+            # if we affected something other then one row something very bad
+            # has happened
             unless ( $rows == 1 ) {
                 $log->logdie( "affected row count is $rows instead of 1" );
@@ -1016,5 +1048,7 @@
 }
 
-sub stat_object {
+
+sub stat_object
+{
     my $self = shift;
 
@@ -1123,5 +1157,7 @@
 }
 
-sub _is_valid_object_key  {
+
+sub _is_valid_object_key
+{
     my ($self, $key) = @_;
 
@@ -1149,5 +1185,7 @@
 }
 
-sub _is_valid_volume_name  {
+
+sub _is_valid_volume_name
+{
     my ($self, $vol_name) = @_;
 
@@ -1176,5 +1214,7 @@
 }
 
-sub DESTROY {
+
+sub DESTROY
+{
     my $self = shift;
 
Index: /trunk/Nebulous-Server/t/05_server_lock_object.t
===================================================================
--- /trunk/Nebulous-Server/t/05_server_lock_object.t	(revision 13202)
+++ /trunk/Nebulous-Server/t/05_server_lock_object.t	(revision 13203)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 05_server_lock_object.t,v 1.7 2007-03-28 21:32:54 jhoblitt Exp $
+# $Id: 05_server_lock_object.t,v 1.8 2007-05-03 22:10:14 jhoblitt Exp $
 
 use strict;
@@ -52,5 +52,5 @@
     $neb->lock_object("foo", "read");
 };
-like($@, qr/storage object does not exist/, "storage object does not exist");
+like($@, qr/is valid object key/, "storage object does not exist");
 
 Test::Nebulous->setup;
@@ -59,5 +59,5 @@
     $neb->lock_object("foo", "write");
 };
-like($@, qr/storage object does not exist/, "storage object does not exist");
+like($@, qr/is valid object key/, "storage object does not exist");
 
 Test::Nebulous->setup;
@@ -101,4 +101,6 @@
 
 eval {
+    $neb->create_object("foo");
+
     $neb->lock_object("foo");
 };
@@ -108,4 +110,6 @@
 
 eval {
+    $neb->create_object("foo");
+
     $neb->lock_object("foo", "both");
 };
@@ -115,4 +119,6 @@
 
 eval {
+    $neb->create_object("foo");
+
     $neb->lock_object("foo", 'read', 3);
 };
Index: /trunk/Nebulous-Server/t/06_server_unlock_object.t
===================================================================
--- /trunk/Nebulous-Server/t/06_server_unlock_object.t	(revision 13202)
+++ /trunk/Nebulous-Server/t/06_server_unlock_object.t	(revision 13203)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 06_server_unlock_object.t,v 1.7 2007-03-28 21:41:11 jhoblitt Exp $
+# $Id: 06_server_unlock_object.t,v 1.8 2007-05-03 22:10:14 jhoblitt Exp $
 
 use strict;
@@ -59,5 +59,5 @@
     $neb->unlock_object("foo", "read");
 };
-like($@, qr/storage object does not exist/, "storage object does not exist");
+like($@, qr/is valid object key/, "storage object does not exist");
 
 Test::Nebulous->setup;
@@ -66,5 +66,5 @@
     $neb->unlock_object("foo", "write");
 };
-like($@, qr/storage object does not exist/, "storage object does not exist");
+like($@, qr/is valid object key/, "storage object does not exist");
 
 Test::Nebulous->setup;
@@ -116,4 +116,6 @@
 
 eval {
+    $neb->create_object("foo");
+
     $neb->unlock_object("foo");
 };
@@ -123,4 +125,6 @@
 
 eval {
+    $neb->create_object("foo");
+
     $neb->unlock_object("foo", "both");
 };
@@ -130,4 +134,6 @@
 
 eval {
+    $neb->create_object("foo");
+
     $neb->unlock_object("foo", 'read', 3);
 };
Index: /trunk/Nebulous-Server/t/13_server_rename_object.t
===================================================================
--- /trunk/Nebulous-Server/t/13_server_rename_object.t	(revision 13202)
+++ /trunk/Nebulous-Server/t/13_server_rename_object.t	(revision 13203)
@@ -3,10 +3,10 @@
 # Copryight (C) 2007  Joshua Hoblitt
 #
-# $Id: 13_server_rename_object.t,v 1.1 2007-04-28 00:44:58 jhoblitt Exp $
+# $Id: 13_server_rename_object.t,v 1.2 2007-05-03 22:10:14 jhoblitt Exp $
 
 use strict;
 use warnings FATAL => qw( all );
 
-use Test::More tests => 5;
+use Test::More tests => 6;
 
 use lib qw( ./t ./lib );
@@ -37,4 +37,15 @@
 Test::Nebulous->setup;
 
+# destination key exists
+eval {
+    $neb->create_object('foo');
+    $neb->create_object('bar');
+
+    $neb->rename_object('foo', 'bar');
+};
+like($@, qr/is not valid object key/, "too few params");
+
+Test::Nebulous->setup;
+
 eval {
     $neb->rename_object();
@@ -42,14 +53,18 @@
 like($@, qr/2 were expected/, "no params");
 
-Test::Nebulous->cleanup;
+Test::Nebulous->setup;
 
 eval {
+    $neb->create_object("foo");
+
     $neb->rename_object("foo");
 };
 like($@, qr/2 were expected/, "too few params");
 
-Test::Nebulous->cleanup;
+Test::Nebulous->setup;
 
 eval {
+    $neb->create_object("foo");
+
     $neb->rename_object("foo", "bar", "baz");
 };
Index: /trunk/Nebulous-Server/t/14_server_xattr.t
===================================================================
--- /trunk/Nebulous-Server/t/14_server_xattr.t	(revision 13202)
+++ /trunk/Nebulous-Server/t/14_server_xattr.t	(revision 13203)
@@ -3,5 +3,5 @@
 # Copryight (C) 2007  Joshua Hoblitt
 #
-# $Id: 14_server_xattr.t,v 1.1 2007-05-01 02:00:07 jhoblitt Exp $
+# $Id: 14_server_xattr.t,v 1.2 2007-05-03 22:10:14 jhoblitt Exp $
 
 use strict;
@@ -114,4 +114,6 @@
 
 eval {
+    $neb->create_object('foo');
+
     $neb->setxattr_object('foo', 'bar');
 };
@@ -121,4 +123,6 @@
 
 eval {
+    $neb->create_object('foo');
+
     $neb->setxattr_object('foo', 'bar', 'baz');
 };
@@ -128,4 +132,6 @@
 
 eval {
+    $neb->create_object('foo');
+
     $neb->setxattr_object('foo', 'bar', 'baz', 'create', 'quix');
 };
@@ -137,4 +143,6 @@
 
 eval {
+    $neb->create_object('foo');
+
     $neb->listxattr_object();
 };
@@ -144,4 +152,6 @@
 
 eval {
+    $neb->create_object('foo');
+
     $neb->listxattr_object('foo', 'bar');
 };
@@ -160,4 +170,6 @@
 
 eval {
+    $neb->create_object('foo');
+
     $neb->getxattr_object('foo');
 };
@@ -167,4 +179,6 @@
 
 eval {
+    $neb->create_object('foo');
+
     $neb->getxattr_object('foo', 'bar', 'baz');
 };
Index: /trunk/Nebulous/lib/Nebulous/Server.pm
===================================================================
--- /trunk/Nebulous/lib/Nebulous/Server.pm	(revision 13202)
+++ /trunk/Nebulous/lib/Nebulous/Server.pm	(revision 13203)
@@ -1,5 +1,5 @@
 # Copyright (c) 2004  Joshua Hoblitt
 #
-# $Id: Server.pm,v 1.33 2007-05-03 03:21:28 jhoblitt Exp $
+# $Id: Server.pm,v 1.34 2007-05-03 22:10:13 jhoblitt Exp $
 
 package Nebulous::Server;
@@ -244,7 +244,14 @@
         {
             type        => SCALAR,
-        },
-        {
-            type        => SCALAR,
+            callbacks   => {
+                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
+            },
+        },
+        # make sure the "newkey" doesn't already exist
+        {
+            type        => SCALAR,
+            callbacks   => {
+                'is not valid object key' => sub { not $self->_is_valid_object_key($_[0]) },
+            },
         },
     );
@@ -382,5 +389,6 @@
 }
 
-sub lock_object {
+sub lock_object
+{
     my $self = shift;
 
@@ -388,4 +396,7 @@
         {
             type        => SCALAR,
+            callbacks   => {
+                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
+            },
         },
         {
@@ -501,5 +512,6 @@
 }
 
-sub unlock_object {
+sub unlock_object
+{
     my $self = shift;
 
@@ -507,4 +519,7 @@
         {
             type        => SCALAR,
+            callbacks   => {
+                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
+            },
         },
         {
@@ -635,4 +650,7 @@
         {
             type        => SCALAR,
+            callbacks   => {
+                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
+            },
         },
         {
@@ -706,4 +724,7 @@
         {
             type        => SCALAR,
+            callbacks   => {
+                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
+            },
         },
         {
@@ -751,4 +772,7 @@
         {
             type        => SCALAR,
+            callbacks   => {
+                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
+            },
         },
     );
@@ -789,4 +813,7 @@
         {
             type        => SCALAR,
+            callbacks   => {
+                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
+            },
         },
         {
@@ -831,5 +858,6 @@
 
 
-sub find_objects {
+sub find_objects
+{
     my $self = shift;
 
@@ -870,5 +898,6 @@
 
 
-sub find_instances {
+sub find_instances
+{
     my $self = shift;
 
@@ -939,5 +968,7 @@
 }
 
-sub delete_instance {
+
+sub delete_instance
+{
     my $self = shift;
 
@@ -983,5 +1014,6 @@
             my $rows = $query->execute( $uri );
             
-            # if we affected something other then one row something very bad has happened
+            # if we affected something other then one row something very bad
+            # has happened
             unless ( $rows == 1 ) {
                 $log->logdie( "affected row count is $rows instead of 1" );
@@ -1016,5 +1048,7 @@
 }
 
-sub stat_object {
+
+sub stat_object
+{
     my $self = shift;
 
@@ -1123,5 +1157,7 @@
 }
 
-sub _is_valid_object_key  {
+
+sub _is_valid_object_key
+{
     my ($self, $key) = @_;
 
@@ -1149,5 +1185,7 @@
 }
 
-sub _is_valid_volume_name  {
+
+sub _is_valid_volume_name
+{
     my ($self, $vol_name) = @_;
 
@@ -1176,5 +1214,7 @@
 }
 
-sub DESTROY {
+
+sub DESTROY
+{
     my $self = shift;
 
Index: /trunk/Nebulous/t/05_server_lock_object.t
===================================================================
--- /trunk/Nebulous/t/05_server_lock_object.t	(revision 13202)
+++ /trunk/Nebulous/t/05_server_lock_object.t	(revision 13203)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 05_server_lock_object.t,v 1.7 2007-03-28 21:32:54 jhoblitt Exp $
+# $Id: 05_server_lock_object.t,v 1.8 2007-05-03 22:10:14 jhoblitt Exp $
 
 use strict;
@@ -52,5 +52,5 @@
     $neb->lock_object("foo", "read");
 };
-like($@, qr/storage object does not exist/, "storage object does not exist");
+like($@, qr/is valid object key/, "storage object does not exist");
 
 Test::Nebulous->setup;
@@ -59,5 +59,5 @@
     $neb->lock_object("foo", "write");
 };
-like($@, qr/storage object does not exist/, "storage object does not exist");
+like($@, qr/is valid object key/, "storage object does not exist");
 
 Test::Nebulous->setup;
@@ -101,4 +101,6 @@
 
 eval {
+    $neb->create_object("foo");
+
     $neb->lock_object("foo");
 };
@@ -108,4 +110,6 @@
 
 eval {
+    $neb->create_object("foo");
+
     $neb->lock_object("foo", "both");
 };
@@ -115,4 +119,6 @@
 
 eval {
+    $neb->create_object("foo");
+
     $neb->lock_object("foo", 'read', 3);
 };
Index: /trunk/Nebulous/t/06_server_unlock_object.t
===================================================================
--- /trunk/Nebulous/t/06_server_unlock_object.t	(revision 13202)
+++ /trunk/Nebulous/t/06_server_unlock_object.t	(revision 13203)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 06_server_unlock_object.t,v 1.7 2007-03-28 21:41:11 jhoblitt Exp $
+# $Id: 06_server_unlock_object.t,v 1.8 2007-05-03 22:10:14 jhoblitt Exp $
 
 use strict;
@@ -59,5 +59,5 @@
     $neb->unlock_object("foo", "read");
 };
-like($@, qr/storage object does not exist/, "storage object does not exist");
+like($@, qr/is valid object key/, "storage object does not exist");
 
 Test::Nebulous->setup;
@@ -66,5 +66,5 @@
     $neb->unlock_object("foo", "write");
 };
-like($@, qr/storage object does not exist/, "storage object does not exist");
+like($@, qr/is valid object key/, "storage object does not exist");
 
 Test::Nebulous->setup;
@@ -116,4 +116,6 @@
 
 eval {
+    $neb->create_object("foo");
+
     $neb->unlock_object("foo");
 };
@@ -123,4 +125,6 @@
 
 eval {
+    $neb->create_object("foo");
+
     $neb->unlock_object("foo", "both");
 };
@@ -130,4 +134,6 @@
 
 eval {
+    $neb->create_object("foo");
+
     $neb->unlock_object("foo", 'read', 3);
 };
Index: /trunk/Nebulous/t/13_server_rename_object.t
===================================================================
--- /trunk/Nebulous/t/13_server_rename_object.t	(revision 13202)
+++ /trunk/Nebulous/t/13_server_rename_object.t	(revision 13203)
@@ -3,10 +3,10 @@
 # Copryight (C) 2007  Joshua Hoblitt
 #
-# $Id: 13_server_rename_object.t,v 1.1 2007-04-28 00:44:58 jhoblitt Exp $
+# $Id: 13_server_rename_object.t,v 1.2 2007-05-03 22:10:14 jhoblitt Exp $
 
 use strict;
 use warnings FATAL => qw( all );
 
-use Test::More tests => 5;
+use Test::More tests => 6;
 
 use lib qw( ./t ./lib );
@@ -37,4 +37,15 @@
 Test::Nebulous->setup;
 
+# destination key exists
+eval {
+    $neb->create_object('foo');
+    $neb->create_object('bar');
+
+    $neb->rename_object('foo', 'bar');
+};
+like($@, qr/is not valid object key/, "too few params");
+
+Test::Nebulous->setup;
+
 eval {
     $neb->rename_object();
@@ -42,14 +53,18 @@
 like($@, qr/2 were expected/, "no params");
 
-Test::Nebulous->cleanup;
+Test::Nebulous->setup;
 
 eval {
+    $neb->create_object("foo");
+
     $neb->rename_object("foo");
 };
 like($@, qr/2 were expected/, "too few params");
 
-Test::Nebulous->cleanup;
+Test::Nebulous->setup;
 
 eval {
+    $neb->create_object("foo");
+
     $neb->rename_object("foo", "bar", "baz");
 };
Index: /trunk/Nebulous/t/14_server_xattr.t
===================================================================
--- /trunk/Nebulous/t/14_server_xattr.t	(revision 13202)
+++ /trunk/Nebulous/t/14_server_xattr.t	(revision 13203)
@@ -3,5 +3,5 @@
 # Copryight (C) 2007  Joshua Hoblitt
 #
-# $Id: 14_server_xattr.t,v 1.1 2007-05-01 02:00:07 jhoblitt Exp $
+# $Id: 14_server_xattr.t,v 1.2 2007-05-03 22:10:14 jhoblitt Exp $
 
 use strict;
@@ -114,4 +114,6 @@
 
 eval {
+    $neb->create_object('foo');
+
     $neb->setxattr_object('foo', 'bar');
 };
@@ -121,4 +123,6 @@
 
 eval {
+    $neb->create_object('foo');
+
     $neb->setxattr_object('foo', 'bar', 'baz');
 };
@@ -128,4 +132,6 @@
 
 eval {
+    $neb->create_object('foo');
+
     $neb->setxattr_object('foo', 'bar', 'baz', 'create', 'quix');
 };
@@ -137,4 +143,6 @@
 
 eval {
+    $neb->create_object('foo');
+
     $neb->listxattr_object();
 };
@@ -144,4 +152,6 @@
 
 eval {
+    $neb->create_object('foo');
+
     $neb->listxattr_object('foo', 'bar');
 };
@@ -160,4 +170,6 @@
 
 eval {
+    $neb->create_object('foo');
+
     $neb->getxattr_object('foo');
 };
@@ -167,4 +179,6 @@
 
 eval {
+    $neb->create_object('foo');
+
     $neb->getxattr_object('foo', 'bar', 'baz');
 };
Index: /trunk/Nebulous/t/63_client_stat.t
===================================================================
--- /trunk/Nebulous/t/63_client_stat.t	(revision 13202)
+++ /trunk/Nebulous/t/63_client_stat.t	(revision 13203)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 63_client_stat.t,v 1.2 2007-05-01 02:52:04 jhoblitt Exp $
+# $Id: 63_client_stat.t,v 1.3 2007-05-03 22:10:14 jhoblitt Exp $
 
 use strict;
@@ -10,5 +10,5 @@
 use Apache::Test qw( -withtestmore );
 
-plan tests => 11;
+plan tests => 12;
 
 use lib qw( ./t ./lib );
@@ -30,5 +30,5 @@
     my $info = $neb->stat( "foo" );
 
-    is( scalar @$info, 6, "number of columns" );
+    is( scalar @$info, 7, "number of columns" );
 }
 
@@ -43,5 +43,5 @@
     my $info = $neb->stat( "foo" );
 
-    is( scalar @$info, 6,                       "number of columns" );
+    is( scalar @$info, 7,                       "number of columns" );
     is( @$info[0], 1,                           "so_id" );
     is( @$info[1], "foo",                       "ext_id" );
@@ -50,4 +50,5 @@
     like( @$info[4], qr/....-..-.. ..:..:../,   "epoch" );
     like( @$info[5], qr/....-..-.. ..:..:../,   "mtime" );
+    is( @$info[6], 1,                           "instances" );
 }
 
