Connecting with user name and password

To write a batch program it is not possible to re-use a connected user’s login information as we did in most of the other examples. Instead we need a real login with a user name and password.

jRQL is able to connect to RedDot CMS with the following line of code:

CmsClient client = new CmsClient(new PasswordAuthentication(“username”, “password”));

This line is very similar to a normal login via the browser, but this line did not jump directly into your last project you worked in.

Instead you have two possibilities to select a project, by project GUID or by project name:

Project project = client.getProjectByGuid("project guid");
Project project = client.getProjectByName("project name");

Depending on your environment you have to decide what you want to use. Configuring the project GUID is very stable, because this project GUID did not change. The project name therefore might change sometimes, but is much better readable as a program parameter.

I often use a colon separated list of project names to iterate through them for e.g. collect statistical information, like connected users.

String user = args[0];
String pw= args[1];
String[] projectNames = StringHelper.split(args[2], ",");

CmsClient client = new CmsClient(new PasswordAuthentication(user, pw));

for (int i = 0; i < projectNames.length; i++) {
String projectName = projectNames[i];
Project project = client.getProjectByName(projectName);

// do what you want


Take this as a skeleton to start with your own batch programming. Don’t forget to use a finally block at the end to disconnect from the RedDot CMS after your job is finished.


I recommend to create a new user in ServerManager for every batch program to need. If you batch program is interrupted unexpectedly remember to disconnect this batch program user from to prevent the UserAlreadyLoggedInException.  Simply log in via the browser with this user, confirm the warning message and log off to prepare a next run of your batch program.

Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: