Complete Example Program - EnterWorks_Process_Exchange_(EPX) - 10.6

EnterWorks EPX Programmers Reference

Product type
Software
Portfolio
Verify
Product family
EnterWorks
Product
Precisely EnterWorks > EnterWorks Process Exchange (EPX)
Version
10.6
Language
English
Product name
Precisely EnterWorks
Title
EnterWorks EPX Programmers Reference
Topic type
Programming Reference
Reference
First publish date
2007
ft:lastEdition
2023-07-28
ft:lastPublication
2023-09-20T04:07:07.148709

This section provides the complete code for the main program used in the example code for locally managing users and groups. It illustrates the calls needed to log in the user, add a user, list all the users to ensure that the one added was created, update the user just added, and then remove a user. The example then demonstrates how to create a new group with a list of members created in the example.

There are no additional program parameters for this example other than those specified in the LoginExample program (found on page 16).

Note: Users should run the sample script using their specific username and password. For example:

C:\Enterworks\EPX\examples\api\run.bat UserGroupExample

-server EPX_somehost -user system -password system

public static void main(String args[]) throws Exception

{

try

{

String serverUID = null;

String user = "system";

String password = "system";

for ( int i=0 ; i < args.length; i++)

{

String arg = args[i];

if (arg.startsWith("-"))

{

if (arg.substring(1).equals("server"))

serverUID = args[++i];

else if (arg.substring(1).equals("user"))

user = args[++i];

else if (arg.substring(1).equals("password"))

password = args[++i];

}

}

UserGroupExample example =

new UserGroupExample(serverUID, user, password);

// login

example.login();

UserVO createdUser = null;

// create a user

try

{

createdUser = example.createUser();

String vargs[] = {createdUser.getLogin()};

System.err.println(example.getMessage

("user.group.create.us er",vargs));

// show all users example.showUsers();

}

catch ( Exception e )

{

String vargs[] = { e.toString() };

System.err.println(example.getMessage

("user.group.create.us er.exception",vargs));

}

// update the user just created

if ( createdUser != null )

{

try

{

// update some user information and password

// for the user just created above

UserVO updatedUser = example.updateUser

(createdUser.getPrimaryKey() );

String vargs[] ={createdUser.getLogin()};

System.err.println(example.getMessage

("user.group.update.user", vargs));

// show all users

example.showUsers();

// now delete the user just updated

if ( updatedUser != null )

{

try

{

// update some user information and

// password for the user just

// created above

example.deleteUser

(updatedUser.getPrimaryKey());

String vargsDelete[]=

{updatedUser.getLogin()};

System.err.println

(example.getMessage(

"user.group.delete.user",

vargsDelete));

// show all users

example.showUsers();

}

catch ( Exception e )

{

String vargsDelete[] = {e.toString() };

System.err.println

(example.getMessage(

"user.group.delete.

us er.exception",

vargsDelete));

}

}

catch ( Exception e )

{

String vargs[] = { e.toString() };

System.err.println(example.getMessage(

"user.group.update.user.exception",

vargs));

}

}

try

{

// create a new group with a collection

// of popular users

example.createGroup();

System.err.println(example.getMessage(

"user.group.create.gr oup"));

}

catch ( Exception e )

{

String vargs[] = { e.toString() };

System.err.println(example.getMessage(

"user.group.create.gr oup.exception",

vargs));

}

// logout

example.logout();

}

catch( Exception e )

{

System.err.println("UserGroupExample.main(

exception):" + e );

e.printStackTrace();

}

}