Accessing different CMS servers

In the article before I explained how to access 2 projects on the same CMS server. If you work with several installations, maybe per stage (production, test, and so on), you need to access different servers at the same time.

jRQL offers in general 2 possibilities to connect: via existing session data (logon GUID, session key) and by user name and password. Both cases can be extended to connect different CMS servers.

In both cases you need to adjust the client object creation with the URL of the bridge ASP who uses jRQL for communication with the CMS.

See first re-using existing session data in the following lines of code.

String logonGuidOld="36AE9002974742C48B5F38AD889A51A2";
String sessionKeyOld="72EF63F6333B4C01AD4B568974B95424";
String projectGuidOld="06BE79A1D9F549388F06F6B649E27152";

CmsClient clientOld = new CmsClient(logonGuidOld, new URL(“http://reddot.hlcl.com/cms/hlclRemoteRql.asp”));
Project projectOld = clientOld.getProject(sessionKeyOld, projectGuidOld);

String logonGuid=”7DDFD5482B57475A9004584FC6C1F207″;
String sessionKey=”1A7CF419554244B9B737DFC3D23D13A5″;
String projectGuid=”73671509FA5C43ED8FC4171AD0298AD2″;

CmsClient client = new CmsClient(logonGuid, new URL(“http://kswfrd02/cms/hlclRemoteRql.asp”));
Project project = client.getProject(sessionKey, projectGuid);

// by old page id
Page sourcePg = projectOld.getPageById(“127290”);
System.out.println(sourcePg.getInfoText());

// by new page id
Page targetPg = project.getPageById(“2”);
System.out.println(targetPg.getInfoText());

The important point here is the creation of client objects clientOld and client. You see, that they access a CMS installation on reddot.hlcl.com and kswfrd02. Don’t forget to copy the hlclRemoteRql.asp file into \CMS\ASP directory.

If you need to access several projects on different CMS servers by user name and password, use the style below. The only difference is the creation of the client1 and client2 objects, where the helper class PasswordAuthentication is used to hold user name and password. The rest is similar.

CmsClient client1 = new CmsClient(new PasswordAuthentication("lejafr", "pw"), new URL("http://reddot.hlcl.com/cms/hlclRemoteRql.asp"));
Project project1 = client1.getProjectByName("hip.hlcl.com");

CmsClient client2 = new CmsClient(new PasswordAuthentication(“lejafradm”, “pw”), new URL(“http://kswfrd02/cms/hlclRemoteRql.asp”));
Project project2 = client2.getProjectByName(“hlag_wm2008”);

Page source1Pg = project1.getPageById(“127290”);
System.out.println(source1Pg.getInfoText());

// by new page id
Page target2Pg = project2.getPageById(“2”);
System.out.println(target2Pg.getInfoText());

client1.disconnect();
client2.disconnect();

In this example it is important to logoff both users from the CMS with the disconnect() methods. In practice I recommend to use it within a finally block.

You find the source code within the respective sample class in the jRQL download.

Advertisements
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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: