/* * * Copyright (c) 1999 - 2011 my-Channels Ltd * Copyright (c) 2012 - 2017 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors. * * Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG. * */ #include "nSampleApp.h" #include "nDataGroupListener.h" #include "nDataStreamListener.h" #include "nSession.h" #include "nDataGroup.h" #include "nEventProperties.h" #include "nConsumeEvent.h" #include "nSessionNotConnectedException.h" #include "nBaseClientException.h" #include "nSessionPausedException.h" #include "nSecurityException.h" #include "nSessionFactory.h" #include "nUnexpectedResponseException.h" #include "nRequestTimedOutException.h" #include using namespace com::pcbsys::nirvana::client; using namespace com::pcbsys::nirvana::apps; class deleteDataGroup : public nSampleApp, public nDataStreamListener { private: static deleteDataGroup *m_pSelf; /** * This method demonstrates the Nirvana API calls necessary to delete * an nDataGroup. * It is called after all command line arguments have been received and * validated * * @param realmDetails a String[] containing the possible RNAME values * @param groupName the data group name to delete */ private: void doit(std::string *pRealmDetails, int nRealmDetail, const std::string& groupName) { m_pSelf->constructSession(pRealmDetails, nRealmDetail, this); try { std::list *pGrps = m_pSession->getDataGroups(); m_pSession->deleteDataGroup(groupName); delete pGrps; //Inform the user of the resulting deletion printf("nDataGroup now removed"); } catch (nSessionPausedException ps) { printf("Session has been paused, please resume the session\n"); exit(1); } catch (nSecurityException se) { printf("Unsufficient permissions for the requested operation.\n"); printf("Please check the ACL settings on the server.\n"); exit(1); } catch (nSessionNotConnectedException snce) { printf("The session object used is not physically connected to the Nirvana realm.\n"); printf("Please ensure the realm is up and check your RNAME value.\n"); exit(1); } catch (nUnexpectedResponseException ure) { printf("The Nirvana REALM has returned an unexpected response.\n"); printf("Please ensure the Nirvana REALM and client API used are compatible.\n"); exit(1); } catch (nRequestTimedOutException rtoe) { printf("The requested operation has timed out waiting for a response from the REALM.\n"); printf("If this is a very busy REALM ask your administrator to increase the client timeout values.\n"); exit(1); } //Close the session we opened try { nSessionFactory::close(m_pSession); } catch (Exception ex) { } //Close any other sessions so that we can exit nSessionFactory::shutdown(); } // callback for DataStreamListener public: ~deleteDataGroup() { } void onMessage(nConsumeEvent *pEvt) { } protected: virtual void processArgs(int argc, char** argv) { // // Need a min of 3, rname, group name if (argc < 3) { Usage(); exit(2); } std::string RNAME = argv[1]; std::string groupName = argv[2]; // // Run the sample app // int nRproperty = 0; std::string *pRproperties = parseRealmProperties(RNAME, nRproperty); m_pSelf->doit(pRproperties, nRproperty, groupName); delete[] pRproperties; } public: static int Main(int argc, char** argv) { //Create an instance for this class m_pSelf = new deleteDataGroup(); //Process command line arguments m_pSelf->processArgs(argc, argv); return 0; } /** * Prints the usage message for this class */ private: static void Usage() { printf("Usage ...\n\n"); printf("deleteDataGroup \n\n"); printf(" \n\n"); printf(" - the rname of the server to connect to\n"); printf(" - Data group name parameter to delete\n"); } deleteDataGroup() { } }; deleteDataGroup* deleteDataGroup::m_pSelf = NULL; int main (int argc, char** argv) { return deleteDataGroup::Main (argc, argv); }