Pagina Principale   Moduli   Lista dei namespaces   Gerarchia delle classi   Lista in ordine alfabetico   Lista dei composti   Lista dei files   Membri dei namespaces   Membri dei composti   Membri dei files   Esempi  

OMremove.cc

Rimuove un oggetto dalla parte di repository controllata da un determinato ObjectManager.

/*
 *    FBFS Distributed Object Repository
 *    Copyright (C) 2001 Francesco V. Bassi
 *
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include <iostream.h>
#include "../../Object/Object.h"
#include "../../idl/NameServer.hh"
#include "../../idl/Object.hh"
#include "../../idl/Security.hh"
#include "../../idl/ObjectManager.hh"
#include "../../utils/NameServer.h"
#include "../../utils/URI.h"
#include "../../utils/File.h"

using namespace fbfs;

int
main (int argc, char **argv) 
{
    try {
        CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB3");

        if(argc != 3) {
            cerr << "Usage: " << argv[0] << " <OM_address> <Id>\n";
            return 0;
        };

        utils::URI uri(argv[1]);
        if(!uri.isValid()) {
            cerr << "Error: address not valid.\n";
            orb->destroy();
            exit(1);
        };
        
        CORBA::Object_var obj = utils::NameServer::get_object(orb, uri);
        fbfs::ObjectManager_var server = fbfs::ObjectManager::_narrow(obj);
        if(CORBA::is_nil(server)) {
            cerr << "Error: the address doesn't refer an ObjectManager object.\n";
            orb->destroy();
            exit(1);
        };
        
        Security cert;
        Obj_id id;
        id.name = CORBA::string_dup(argv[2]);
        
        try { server->remove(cert, id); }
        catch (NotFound) { cerr << "Error: item not found.\n"; }
        catch (SecurityException) { cerr << "Error: insufficient security permissions.\n"; }
        catch (InternalError) { cerr << "Error: internal error.\n"; }
        catch (...) { cerr << "Error: very, very strange.\n"; };        
        orb->destroy();
    }
    catch(CORBA::COMM_FAILURE& ex) {
        cerr << "Caught system exception COMM_FAILURE -- unable to contact the "
         << "object." << endl;
    }
    catch(CORBA::SystemException&) {
        cerr << "Caught CORBA::SystemException." << endl;
    }
    catch(CORBA::Exception&) {
        cerr << "Caught CORBA::Exception." << endl;
    }
    catch(omniORB::fatalException& fe) {
        cerr << "Caught omniORB::fatalException:" << endl;
        cerr << "  file: " << fe.file() << endl;
        cerr << "  line: " << fe.line() << endl;
        cerr << "  mesg: " << fe.errmsg() << endl;
    }
    catch(...) {
        cerr << "Caught unknown exception." << endl;
    }
    return 0;
}

Generato il Thu Feb 15 13:24:56 2001 per A Simple Distributed Object Repository with CORBA & C++. da doxygen1.2.3 scritto da Dimitri van Heesch, © 1997-2000