The following topic will show you a sample program that allows you to start or stop any clientA closed environment within an Automation Engine system where you can create and run objects. A client name consists of a 4-digit number that must be indicated when a user logs on to the Automation Engine system. Users and their rights are also defined in clients. A particular Automation Engine object type. by using the Java Application Interface.
You can use the existing Java code or adjust it according to your requirements.
Use the following command-line parameters in order to call the sample program:
java aeClientGoStop <go/stop> <cp> <port> <client> <userIn the Automation Engine, a user is an instance of a User object, and generally the user is a specific person who works with Automic products. The User object is assigned a user ID and then a set of access rights to various parts of the Automation Engine system and product suite. These access rights come in the form of Automation Engine authorizations and privileges, Decision user roles and EventBase rights and ARA web application object rights. You can manage all these centrally in the ECC user management functions. See also, Unified user management.> <dep> <pwd>
To be able to call the program successfully, you will need the Java Application Interface (uc4.jar).
import java.io.IOException;
import com.uc4.communication.Connection;
import com.uc4.communication.requests.CreateSession;
import com.uc4.communication.requests.ResumeClient;
import com.uc4.communication.requests.SuspendClient;
import com.uc4.communication.requests.XMLRequest;
public class aeClientGoStop {
public static void main(String[] args) throws IOException {
new aeClientGoStop().gostop(args);
}
private void gostop(String[] args) throws IOException {
int count = args.length;
if(count < 6){
System.err.println("not enough arguments: min = 6 -> found only: " + count);
System.exit(1);
}
//System.err.println("arguments passed on: " + count);
String action = null;
String cp = null;
String port = null;
String client = null;
String user = null;
String dep = null;
String pwd = null;
if(count < 7){
action = args[0];
cp = args[1];
port = args[2];
client = args[3];
user = args[4];
dep = args[5];
pwd = "";
}else if(count == 7){
action = args[0];
cp = args[1];
port = args[2];
client = args[3];
user = args[4];
dep = args[5];
pwd = args[6];
}
//Create a connection to the Automation Engine
Connection uc4 = Connection.open(cp, Integer.parseInt(port));
//Login
CreateSession login = uc4.login(Integer.parseInt(client),user,dep,pwd,'E');
//Test if the login was successful
if (!login.isLoginSuccessful()) {
System.err.println(login.getMessageBox().getText());
uc4.close();
System.exit(1);
}
XMLRequest rqr = null ;
if (action.equals("go")){
rqr = new ResumeClient();
} else if (action.equals("stop")){
rqr = new SuspendClient();
}
uc4.sendRequestAndWait(rqr);
if (rqr.getMessageBox() != null) {
System.err.println(rqr.getMessageBox().getText());
uc4.close();
System.exit(3);
}
uc4.close();
System.out.println("done action: " + action + " client: " + client);
}
};
Automic Documentation - Tutorials - Automic Blog - Resources - Training & Services - Automic YouTube Channel - Download Center - Support |
Copyright © 2016 Automic Software GmbH |