I need to connect to a 6.5 SP3 docbase and a 7.1 SP1 docbase in the same DFC session and operate on both docbases simultaneously. I was able to connect to both docbases using the code below but errors starting occurring when the code tried to interact with the 6.5 docbase. The interaction with the 7.1 docbase was successful, but as soon as my code started interacting with the 6.5 docbase, then errors occurred. For instance, the server response would indicate I was trying to 'get' the value on an attribute that didn't exist (and one that was not in my code, either). I eventually determined the errors where due to character encoding differences between the two versions. I deleted the DFC/BOF cache and re-published the data dictionary on both 6.5 and 7.1 content servers, but this did not remove the obstacle. My instinct is that this limitation is due to the fact that only ONE global registry docbase can be specified per dfc.properties file.
Any ideas for how to proceed? I am currently implementing a 'middleware' approach where the Java process connects to each docbase in a separate thread, using separate dfc.properties files. The two threads communicate using local temp files. Fun but inefficient.
public static void main(String args[]) {
try {
IDfSessionManager dfSessionManager = null;
IDfClient dfClient = new DfClient();
dfSessionManager = dfClient.newSessionManager();
IDfLoginInfo loginInfo = new DfLoginInfo();
loginInfo.setUser("dmadmin");
loginInfo.setPassword("blah");
dfSessionManager.setIdentity("CLM", loginInfo);
FixMigrationIssues up = new FixMigrationIssues();
up.lSession = dfSessionManager.newSession("CLM");
DfLogger.debug(FixMigrationIssues.class, "main() GO" , null, null);
up.getMissingContent();
} catch ( Exception e ) {
DfLogger.error(FixMigrationIssues.class, "main() " + e.getMessage(), null, null);
}
}
public static IDfSession connectToDocbase1(
String docbaseName,
String username,
String passwd,
String domain,
String docBrokerHost,
String docBrokerPort) throws Exception {
try {
IDfSession session65 = null;
IDfClientX clientX = new DfClientX();
IDfClient client = clientX.getLocalClient();
IDfLoginInfo loginInfo = new DfLoginInfo();
loginInfo.setUser(username);
loginInfo.setPassword(passwd);
loginInfo.setDomain(domain);
if (docBrokerHost != null && docBrokerHost.length() > 0) {
IDfTypedObject apiconfig = client.getClientConfig();
String primaryHost = apiconfig.getString("primary_host");
String primaryPort = apiconfig.getString("primary_port");
apiconfig.setString("primary_host", docBrokerHost);
apiconfig.setString("primary_port", docBrokerPort);
try {
IDfTypedObject serverMap = client.getServerMapEx(
docbaseName, null, docBrokerHost, docBrokerPort);
session65 = client.newSession(docbaseName + "@ + serverMap.getString(i_host_name"), loginInfo);
} catch (Exception e) {
if (primaryHost != null) {
apiconfig.setString("primary_host", primaryHost);
}
if (primaryPort != null) {
apiconfig.setString("primary_port", primaryPort);
}
throw e;
}
apiconfig.setString("primary_host", primaryHost);
apiconfig.setString("primary_port", primaryPort);
} else {
session65 = client.newSession(docbaseName, loginInfo);
}
DfLogger.error(FixMigrationIssues.class, "connectToDocbase1(): Successfully Connected to docbase " + session65.getDocbaseId(), null, null);
return session65;
} catch (Exception ex) {
DfLogger.error(FixMigrationIssues.class, "connectToDocbase1(): failed to connect " + ex.getMessage(), null, null);
throw ex;
}
}