IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23456


Ignore:
Timestamp:
Mar 20, 2009, 10:46:27 AM (17 years ago)
Author:
jhoblitt
Message:

factor out repeated calls to _neb_start() and add an ->nebulous() accessor method

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/PS-IPP-Config/lib/PS/IPP/Config.pm

    r23185 r23456  
    388388    }
    389389
    390     return 1 if defined $self->{nebulous}; # Already started
     390    return $self->{nebulous} if defined $self->{nebulous}; # Already started
    391391
    392392    my $server = metadataLookupStr( $self->{_siteConfig}, 'NEB_SERVER' ); # Nebulous server
     
    404404    $self->{nebulous} = $neb;
    405405
    406     return 1;
     406    return $neb;
     407}
     408
     409sub nebulous
     410{
     411    my $self = shift;
     412    carp "no parameters are allowed" if @_;
     413
     414    # check to see if we already have a live nebulous object
     415    return $self->{nebulous} if defined $self->{nebulous};
     416
     417    # if not, call _neb_start() and return the new object
     418    return _neb_start();
    407419}
    408420
     
    421433
    422434        if ($scheme eq 'neb') {
    423             $self->_neb_start() or ( carp "Can't start Nebulous" and return undef );
    424             my $neb = $self->{nebulous}; # Nebulous handle
     435            my $neb = $self->nebulous; # Nebulous handle
    425436            if ($create_if_doesnt_exist) {
    426437                my $status = eval { $neb->stat( $name ); };
     
    485496        $scheme = lc($scheme);
    486497        if ($scheme eq 'neb') {
    487             $self->_neb_start() or ( carp "Unable to start Nebulous" and return undef );
    488             my $fh = eval { $self->{nebulous}->open_create( $name ); };
     498            my $fh = eval { $self->nebulous->open_create( $name ); };
    489499            if ($@ or not defined $fh) {
    490500                carp "Unable to open/create Nebulous handle $name";
     
    524534        $scheme = lc($scheme);
    525535        if ($scheme eq 'neb') {
    526             $self->_neb_start() or ( carp "Unable to start Nebulous" and return undef );
    527             my $fh = eval { $self->{nebulous}->open_create( $name ) };
     536            my $fh = eval { $self->nebulous->open_create( $name ) };
    528537            if ($@ or not defined $fh) {
    529538                carp "Unable to open/create Nebulous handle $name";
     
    556565    my $scheme = file_scheme($name); # The scheme, e.g., file://, path://
    557566    if (defined $scheme and lc($scheme) eq 'neb') {
    558         $self->_neb_start() or ( carp "Unable to start Nebulous" and return undef );
    559         $name = eval { $self->{nebulous}->create( $name ) };
     567        $name = eval { $self->nebulous->create( $name ) };
    560568        if ($@ or not defined $name) {
    561569            carp "Unable to create Nebulous handle $name";
     
    575583    my $scheme = file_scheme($name); # The scheme, e.g., file://, path://
    576584    if (defined $scheme and lc($scheme) eq 'neb') {
    577         $self->_neb_start() or ( carp "Unable to start Nebulous" and return undef );
    578         my $found = eval { $self->{nebulous}->find_instances( $name ); };
     585        my $found = eval { $self->nebulous->find_instances( $name ); };
    579586        ( carp "Unable to find instances of Nebulous handle $name" and return undef ) if $@;
    580587        return (defined $found ? 1 : 0);
     
    595602    my $scheme = file_scheme($target); # The scheme, e.g., file://, path://
    596603    if (defined $scheme and lc($scheme) eq 'neb') {
    597         $self->_neb_start() or ( carp "Unable to start Nebulous" and return undef );
    598         $target = eval { $self->{nebulous}->create( $target ); };
     604        $target = eval { $self->nebulous->create( $target ); };
    599605        if ($@ or not defined $target) {
    600606            carp "Unable to create Nebulous handle";
     
    646652    my $scheme = file_scheme($name); # The scheme, e.g., file://, path://
    647653    if (defined $scheme and lc($scheme) eq 'neb') {
    648         $self->_neb_start() or ( carp "Unable to start Nebulous" and return undef );
    649         $status = eval { $self->{nebulous}->delete( $name ); };
     654        $status = eval { $self->nebulous->delete( $name ); };
    650655        ( carp "Unable to delete Nebulous handle $name" and return undef ) if $@;
    651656    } else {
Note: See TracChangeset for help on using the changeset viewer.