Nirvana Java Client: Delete a Channel Join
This is a class that demonstrates how to delete a channel join.
Usage
ndelchanjoin <source channel name> <destination channel name> <Required Arguments> <source channel name> - Source Channel name parameter of the join to be deleted <destination channel name> - Destination Channel name parameter of the join to be deleted Note: -? provides help on environment variables
Application Source Code
See also:
/**
*
* ----------------------------------------------------------------------------------
*
* PCB Systems Limited License Version 1.1
* Copyright PCB Systems Limited. All rights reserved
*
* In the event that you should download or otherwise use this software
* ( the "Software" ) you hereby acknowledge and agree that:
*
* 1. The Software is the property of PCB Systems Limited: Title, Copyright and all
* other proprietary rights, interest and benefit in and to the Software is and
* shall be owned by PCB Systems Limited;
*
* 2. You will not make copies of the Software whatsoever other than, if you should
* so wish, a single copy for archival purposes only;
*
* 3. You will not modify, reverse assemble, decompile, reverse engineer or otherwise
* translate the Software;
*
* 4. You will not redistribute, copy, forward electronically or circulate the Software
* to any person for any purpose whatsoever without the prior written consent of
* PCB Systems Limited;
*
* 5. You will not charge for, market or provide any managed service or product that
* is based upon or includes the Software or any variant of it; and
*
* 6. You will not use the Software for any purpose apart from your own personal,
* noncommercial and lawful use;
*
* You hereby agree that the software is used by you on an "as is" basis, without
* warranty of any kind. PCB Systems Limited hereby expressly disclaim all warranties
* and conditions, either expressed or implied, including but not limited to any
* implied warranties or conditions or merchantability and fitness for a particular
* purpose.
*
* You agree that you are solely responsible for determining the appropriateness of
* using the Software and assume all risks associated with it including but not
* limited to the risks of program errors, damage to or loss of of data, programs or
* equipment and unavailability or interruption of operations.
*
* PCB Systems Limited will not be liable for any direct damages or for any, special,
* incidental or indirect damages or for any economic consequential damages ( including
* lost profits or savings ), or any damage howsoever arising.
*
* ----------------------------------------------------------------------------------
*/
package com.pcbsys.nirvana.apps;
import com.pcbsys.nirvana.client.*;
/**
* Deletes a nirvana channel join
*/
public class deleteChannelJoin extends nSampleApp {
private static deleteChannelJoin mySelf=null;
/**
* This method demonstrates the Nirvana API calls necessary to delete
* a channel.
* It is called after all command line arguments have been received and
* validated
*
* @param realmDetails a String[] containing the possible RNAME values
* @param destChannelName the deatination channel name of the join
* @param sourceChannelName the source channel name of the join
*/
private void doit(String[] realmDetails, String destChannelName, String sourceChannelName ) {
mySelf.constructSession(realmDetails);
//Removes the specified channel join
try{
//Create a channels and attributes objects
nChannelAttributes srcattr = new nChannelAttributes();
srcattr.setName( sourceChannelName );
nChannelAttributes dstattr = new nChannelAttributes();
dstattr.setName( destChannelName );
nChannel srcchan = mySession.findChannel(srcattr);
nChannel dstchan = mySession.findChannel(dstattr);
// remove the join
srcchan.deleteJoin(dstchan);
}
//Handle errors
catch(nChannelNotFoundException cnfe){
System.out.println("The channel specified could not be found.");
System.out.println("Please ensure that the channel exists in the REALM you connect to.");
cnfe.printStackTrace();
System.exit(1);
}
catch (nSecurityException se) {
System.out.println("Unsufficient permissions for the requested operation.");
System.out.println("Please check the ACL settings on the server.");
se.printStackTrace();
System.exit(1);
}
catch (nSessionNotConnectedException snce) {
System.out.println("The session object used is not physically connected to the Nirvana realm.");
System.out.println("Please ensure the realm is up and check your RNAME value.");
snce.printStackTrace();
System.exit(1);
}
catch (nUnexpectedResponseException ure) {
System.out.println("The Nirvana REALM has returned an unexpected response.");
System.out.println("Please ensure the Nirvana REALM and client API used are compatible.");
ure.printStackTrace();
System.exit(1);
}
catch (nUnknownRemoteRealmException urre) {
System.out.println("The channel specified resided in a remote realm which could not be found.");
System.out.println("Please ensure the channel name specified is correct.");
urre.printStackTrace();
System.exit(1);
}
catch (nRequestTimedOutException rtoe) {
System.out.println("The requested operation has timed out waiting for a response from the REALM.");
System.out.println("If this is a very busy REALM ask your administrator to increase the client timeout values.");
rtoe.printStackTrace();
System.exit(1);
}
catch (nBaseClientException nbce) {
System.out.println("An error occured while creating the Channel Attributes object.");
nbce.printStackTrace();
System.exit(1);
}
//Close the session we opened
try{
nSessionFactory.close ( mySession );
}
catch(Exception ex){}
//Close any other sessions within this JVM so that we can exit
nSessionFactory.shutdown ( );
}
protected void processArgs(String[] args){
switch (args.length){
case 1:
if (args[0].equals("-?")) {
Usage();
UsageEnv();
}
System.getProperties().put("SRCCHANNAME",args[0]);
break;
case 2:
System.getProperties().put("SRCCHANNAME",args[0]);
System.getProperties().put("DESTCHANNAME",args[1]);
}
}
public static void main( String[] args ) {
//Create an instance for this class
mySelf = new deleteChannelJoin();
//Process command line arguments
mySelf.processArgs(args);
//Process Environment Variables
nSampleApp.processEnvironmentVariables();
//Check the channel name specified
String destChannelName=null;
if ( System.getProperty( "DESTCHANNAME" ) != null )
destChannelName= System.getProperty( "DESTCHANNAME" ) ;
else{
Usage();
System.exit( 1 );
}
String srcChannelName=null;
if ( System.getProperty( "SRCCHANNAME" ) != null )
srcChannelName= System.getProperty( "SRCCHANNAME" ) ;
else{
Usage();
System.exit( 1 );
}
//Check the local realm details
int idx = 0;
String RNAME=null;
if ( System.getProperty( "RNAME" ) != null )
RNAME= System.getProperty( "RNAME" ) ;
else{
Usage();
System.exit( 1 );
}
//Process the local REALM RNAME details
String[] rproperties = new String[4];
rproperties=parseRealmProperties(RNAME);
//delete the channel join specified
mySelf.doit(rproperties, destChannelName, srcChannelName);
}
/**
* Prints the usage message for this class
*/
private static void Usage() {
System.out.println( "Usage ...\n" );
System.out.println("ndelchanjoin <source channel name> <destination channel name> \n");
System.out.println(
"<Required Arguments> \n");
System.out.println(
"<source channel name> - Source Channel name parameter of the join to be deleted" );
System.out.println(
"<destination channel name> - Destination Channel name parameter of the join to be deleted" );
System.out.println(
"\n\nNote: -? provides help on environment variables \n");
}
} // End of deleteChannelJoin Class
EXAMPLE_SOURCE_END
