IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5662


Ignore:
Timestamp:
Dec 2, 2005, 4:26:59 PM (21 years ago)
Author:
jhoblitt
Message:

add Nebulous::Client->open_create()
change Nebulous::Client->create() to return just a filename

Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/Changes

    r5661 r5662  
    22
    330.02
     4    - add Nebulous::Client->open_create()
     5    - change Nebulous::Client->create() to return just a filename
    46    - [nebclient] add nebOpenCreate()
    57    - [nebclient] change nebCreate() to return just a filename
  • trunk/Nebulous-Server/t/11_client_create.t

    r4440 r5662  
    33# Copryight (C) 2004-2005  Joshua Hoblitt
    44#
    5 # $Id: 11_client_create.t,v 1.4 2005-06-30 02:35:06 jhoblitt Exp $
     5# $Id: 11_client_create.t,v 1.5 2005-12-03 02:26:59 jhoblitt Exp $
    66
    77use strict;
     
    2828    );
    2929
    30     my $fh = $neb->create( "foo" );
     30    my $filename = $neb->create( "foo" );
    3131
    32     is( ref $fh, 'GLOB', "good filehandle" );
     32    ok( -e $filename, "good filename" );
    3333}
    3434
     
    4141    );
    4242
    43     my $fh = $neb->create( "foo", 0 );
     43    my $filename = $neb->create( "foo", 0 );
    4444
    45     is( ref $fh, 'GLOB', "good filehandle" );
     45    ok( -e $filename, "good filename" );
    4646}
    4747
     
    5454    );
    5555
    56     my $fh = $neb->create( "foo", 0, "node01" );
     56    my $filename = $neb->create( "foo", 0, "node01" );
    5757
    58     is( ref $fh, 'GLOB', "good filehandle" );
     58    ok( -e $filename, "good filename" );
    5959}
    6060
     
    6767    );
    6868
    69     my $fh = $neb->create( "foo", 0, "node01", "this is foo" );
     69    my $filename = $neb->create( "foo", 0, "node01", "this is foo" );
    7070
    71     is( ref $fh, 'GLOB', "good filehandle" );
     71    ok( -e $filename, "good filename" );
    7272}
    7373
  • trunk/Nebulous/Changes

    r5661 r5662  
    22
    330.02
     4    - add Nebulous::Client->open_create()
     5    - change Nebulous::Client->create() to return just a filename
    46    - [nebclient] add nebOpenCreate()
    57    - [nebclient] change nebCreate() to return just a filename
  • trunk/Nebulous/lib/Nebulous/Client.pm

    r4928 r5662  
    11# Copyright (c) 2004  Joshua Hoblitt
    22#
    3 # $Id: Client.pm,v 1.20 2005-08-31 03:33:24 jhoblitt Exp $
     3# $Id: Client.pm,v 1.21 2005-12-03 02:26:59 jhoblitt Exp $
    44
    55package Nebulous::Client;
     
    127127    $log->debug( "server allocated $uri" );
    128128
     129    my $filename;
     130    eval {
     131        $filename = _get_file_path( $uri );
     132    };
     133    $log->logdie( $@ ) if $@;
     134
     135    $log->debug( "local filename is $filename" );
     136
     137    $log->debug( "leaving" );
     138
     139    return $filename;
     140}
     141
     142sub open_create {
     143    my $self = shift;
     144
     145    my ( $key, @params ) = validate_pos( @_,
     146        {
     147            type        => SCALAR,
     148        },
     149        {
     150            type        => SCALAR,
     151            callbacks   => {
     152                'is + integer' => sub { $_[0] =~ /^\d+$/ },
     153            },
     154            default     => 0,
     155        },
     156        {
     157            type        => SCALAR,
     158            optional    => 1,
     159        },
     160        {
     161            type        => SCALAR,
     162            optional    => 1,
     163        },
     164    );
     165
     166    $log->debug( "entered - @_" );
     167
     168    # how should already existing files be handled?
     169
     170    my $response = $self->{ 'server' }->create_object( $key, @params );
     171    if ( $response->fault ) {
     172        $log->error( $response->faultcode, " - ", $response->faultstring );
     173        $log->debug( "leaving" );
     174
     175        return undef;
     176    }
     177
     178    my $uri = $response->result;
     179
     180    $log->debug( "server allocated $uri" );
     181
    129182    my $fh;
    130183    eval {
     
    497550    );
    498551
    499     $log->debug( "entered - @_" );
     552#    $log->debug( "entered - @_" );
    500553
    501554    my $fh      = $self->open( $key, 'read' );
     
    507560    }
    508561
    509     my $new_fh  = $self->create( $new_key );
     562    my $new_fh  = $self->open_create( $new_key );
    510563    unless ( $new_fh ) {
    511564        $log->debug( "can not open object" );
  • trunk/Nebulous/t/11_client_create.t

    r4440 r5662  
    33# Copryight (C) 2004-2005  Joshua Hoblitt
    44#
    5 # $Id: 11_client_create.t,v 1.4 2005-06-30 02:35:06 jhoblitt Exp $
     5# $Id: 11_client_create.t,v 1.5 2005-12-03 02:26:59 jhoblitt Exp $
    66
    77use strict;
     
    2828    );
    2929
    30     my $fh = $neb->create( "foo" );
     30    my $filename = $neb->create( "foo" );
    3131
    32     is( ref $fh, 'GLOB', "good filehandle" );
     32    ok( -e $filename, "good filename" );
    3333}
    3434
     
    4141    );
    4242
    43     my $fh = $neb->create( "foo", 0 );
     43    my $filename = $neb->create( "foo", 0 );
    4444
    45     is( ref $fh, 'GLOB', "good filehandle" );
     45    ok( -e $filename, "good filename" );
    4646}
    4747
     
    5454    );
    5555
    56     my $fh = $neb->create( "foo", 0, "node01" );
     56    my $filename = $neb->create( "foo", 0, "node01" );
    5757
    58     is( ref $fh, 'GLOB', "good filehandle" );
     58    ok( -e $filename, "good filename" );
    5959}
    6060
     
    6767    );
    6868
    69     my $fh = $neb->create( "foo", 0, "node01", "this is foo" );
     69    my $filename = $neb->create( "foo", 0, "node01", "this is foo" );
    7070
    71     is( ref $fh, 'GLOB', "good filehandle" );
     71    ok( -e $filename, "good filename" );
    7272}
    7373
Note: See TracChangeset for help on using the changeset viewer.