// Several birds with one stone. Getting the server info
// verifies connectivity with the server, and we use the
// results to set the character encoding for future clients
// and confirm the availability of the overview action.
Client client = clientFactory.createClient();
ClientValue serverInfo = client.GetServerInfo();
// Get the server version, which is a string like "9.5.0".
String serverVersion = serverInfo.toString("ServerVersion");
if (LOGGER.isLoggable(Level.INFO))
LOGGER.info("LIVELINK SERVER VERSION: " + serverVersion);
String[] versions = serverVersion.split("\\.");
int majorVersion;
int minorVersion;
if (versions.length >= 2) {
majorVersion = Integer.parseInt(versions[0]);
minorVersion = Integer.parseInt(versions[1]);
} else {
if (LOGGER.isLoggable(Level.WARNING)) {
LOGGER.warning(
"Unable to parse Livelink server version; assuming 9.5.");
}
majorVersion = 9;
minorVersion = 5;
}
// The connector requires Livelink 9.5 or later.
if ((majorVersion < 9) || (majorVersion == 9 && minorVersion < 5)) {
throw new LivelinkException(
"Livelink 9.5 or later is required.", LOGGER,
"unsupportedVersion", new String[] { "9.5" });
}
// Check for Livelink 9.5 or earlier; change overview action
// if needed. We only check for the default entry, because if
// the map has been customized, perhaps the user knows what
// they are doing. If a user has a Livelink 9.5 with an custom
// overview action, they can configure that in the
// displayPatterns and we won't see it. We are leaving the
// modified entry in the map rather than removing it and
// relying on the default action because there are lots and
// lots of documents, and this avoids a map lookup miss in
// getDisplayUrl for every one of them.
if (majorVersion == 9 && minorVersion <= 5) {
Integer docSubType = new Integer(144);
Object action = displayActions.get(docSubType);
if ("overview".equals(action))
displayActions.put(docSubType, "properties");
}
// Set the character encodings in the client factories if needed.
int serverEncoding = serverInfo.toInteger("CharacterEncoding");
if (serverEncoding == Client.CHARACTER_ENCODING_UTF8) {
LOGGER.config("ENCODING: UTF-8");
clientFactory.setEncoding("UTF-8");
if (authenticationClientFactory != null)
authenticationClientFactory.setEncoding("UTF-8");
}
// Check that our user has System Administration rights, get
// the database type, and check the DTreeAncestors table (in
// that order, because we need SA rights for the database type
// queries, and we need the database type for the
// DTreeAncestors queries).
ClientValue userInfo = client.GetUserInfo(username);
int privs = userInfo.toInteger("UserPrivileges");
if ((privs & Client.PRIV_PERM_BYPASS) != Client.PRIV_PERM_BYPASS) {
LOGGER.info("USER PRIVILEGES: " + privs);
throw new ConfigurationException("User " + username +
" does not have Livelink System Administration rights.",