return createDataStore(config, connPool);
}
final ArcSDEDataStore createDataStore(ArcSDEDataStoreConfig config, final ISessionPool connPool)
throws IOException {
ArcSDEDataStore sdeDStore;
ISession session;
try {
session = connPool.getSession(false);
} catch (UnavailableConnectionException e) {
throw new RuntimeException(e);
}
try {
// check to see if our sdk is compatible with this arcsde instance
SeRelease releaseInfo = session.getRelease();
int majVer = releaseInfo.getMajor();
int minVer = releaseInfo.getMinor();
if (majVer == 9 && minVer > 1 && JSDE_CLIENT_VERSION < JSDE_VERSION_91) {
// we can't connect to ArcSDE 9.2 with the arcsde 9.0 jars. It
// just won't
// work when trying to draw maps. Oh well, at least we'll warn
// people.
LOGGER.severe("\n\n**************************\n"
+ "DANGER DANGER DANGER!!! You're using the ArcSDE 9.0 (or earlier) jars with "
+ "ArcSDE "
+ majVer
+ "."
+ minVer
+ " on host '"
+ config.getServerName()
+ "' . "
+ "This PROBABLY WON'T WORK. If you have issues "
+ "or unexplained exceptions when rendering maps, upgrade your ArcSDE jars to version "
+ "9.2 or higher. See http://docs.codehaus.org/display/GEOTOOLS/ArcSDE+Plugin\n"
+ "**************************\n\n");
}
// if a version was specified, verify it exists
final String versionName = config.getVersion();
if (versionName != null && !("".equals(versionName.trim()))) {
session.issue(new Commands.GetVersionCommand(versionName));
}
} finally {
session.dispose();
}
String namespaceUri = config.getNamespaceUri();
if (namespaceUri != null && "".equals(namespaceUri.trim())) {
namespaceUri = null;
}
String versionName = config.getVersion();
if (versionName != null && "".equals(versionName.trim())) {
versionName = null;
}
boolean allowNonSpatialTables = config.isAllowNonSpatialTables();
/**
* Multiple GeoDB Patch
*
* check if directconnect string has a schema Multiple GeoDB Syntax: Oracle 10g user's
* schema geodatabase <schema_name> is the name of the schema that owns the geodatabase.
* sde:oracle10g:/:<schema_name>
*
* Default single GeoDB Syntax: sde:oracle10g or in MultipleGeoDB Notation:
* sde:oracle10g:/:sde
*
* for further infos look at
* http://webhelp.esri.com/arcgisserver/9.3/java/geodatabases/arcsde-2034353163.htm
*/
final String port = config.getPortNumber();
final String[] directConnectParts = port.split(":");
final int length = directConnectParts.length;
final int multiGeoDB = 4;
if (length == multiGeoDB) {
final int multiGeoDBIndex = port.lastIndexOf(":");
final String user_schema = port.substring(multiGeoDBIndex + 1);
versionName = user_schema + ".DEFAULT";
}
sdeDStore = new ArcSDEDataStore(connPool, namespaceUri, versionName, allowNonSpatialTables);
return sdeDStore;
}