We are using arcims java connector to create, update, delete services. it works fine for create and delete. However when we try to update the config file of service (ie : mxd file) the new mxd file is not replaced in the ArcImsSite.sez file. Thus when we restart ArcIms, the service is created with the wrong mxd file.
here is a snippet of what we do to update the service :
ConnectionProxy connectorProxy = new ConnectionProxy();
connectorProxy.setConnectionType(ConnectionProxy.TCP_ADMIN);
connectorProxy.setHost(arcimsHost);
connectorProxy.setPort(arcimsPort);
connectorProxy.setDisplayMessages(false);
configfile = new FileInputStream(ConstantManager.ENV_DIRECTORY+"configuration.properties");
properties.load(configfile);
int ping = connectorProxy.ping(false);
Site site = new Site();
if (ping == ConnectionProxy.PING_FIRST_LOGIN) {
site.setSiteUser(properties.getProperty("ADMIN_AIMS"),
properties.getProperty("PASSWORD_AIMS"),
connectorProxy);
} else if (ping == ConnectionProxy.PING_OK) {
connectorProxy.setUsername(properties.getProperty("ADMIN_AIMS"));
connectorProxy.setPassword(properties.getProperty("PASSWORD_AIMS")); site.setSiteUser(properties.getProperty("USER_AIMS"), properties.getProperty("PASSWORD_AIMS"), connectorProxy);
} else if (ping == ConnectionProxy.PING_FAIL) {
LoggerManager.logError(LOG, ConstantManager.BUSINESS_TYPE, null);
throw new BusinessException(AdminErrorMessage.ARCIMS_NOT_AVAILABLE, null);
}
ServiceCollection serviceCollection = ServiceCollection.getServices(connectorProxy);
for (int i = 0; i < serviceCollection.size(); i++) {
Service aservice = serviceCollection.getService(i);
// delete the old service
if (aservice.getName().equals(mapBefore.getMapName())) {
LOG.debug("\t-->INPUT BUSINESS LAYER on updateMap METHOD : suppression du service ");
serviceCollection.removeService(aservice);
aservice.removeService(connectorProxy);
}
}
//Here i try to save the site config with site.save(connectorProxy). However the service is //deleted from ArcImsSite.sez file by doing this
//Recreate the connexion
ConnectionProxy connectorProxy = new ConnectionProxy();
connectorProxy.setConnectionType(ConnectionProxy.TCP_ADMIN);
connectorProxy.setHost(arcimsHost);
connectorProxy.setPort(arcimsPort);
connectorProxy.setDisplayMessages(false);
int ping = connectorProxy.ping(false);
Site site = new Site();
if (ping == ConnectionProxy.PING_FIRST_LOGIN) {
site.setSiteUser(properties.getProperty(USER_AIMS"),
properties.getProperty("PASSWORD_AIMS"),
connectorProxy);
} else if (ping == ConnectionProxy.PING_OK) {
connectorProxy.setUsername(properties.getProperty("USER_AIMS"));
connectorProxy.setPassword(properties.getProperty("PASSWORD_AIMS")); site.setSiteUser(properties.getProperty("USER_AIMS"), properties.getProperty("PASSWORD_AIMS"), connectorProxy);
} else if (ping == ConnectionProxy.PING_FAIL) {
LoggerManager.logError(LOG, ConstantManager.BUSINESS_TYPE, null);
throw new BusinessException(AdminErrorMessage.ARCIMS_NOT_AVAILABLE, null);
}
//Create the new service. Actually same service as previous but with new mxd file.
Service myservice = new Service();
//.... adding required information to new service
myservice.setConfigFile(mxdFilePath);
myservice.setConfigFileLength(buff.length);
myservice.setConfigContents(bais, true);
//....
//Save current service config
if (!site.save(connectorProxy)) {
throw new BusinessException(AdminErrorMessage.SERVICE_CONFIG_CANT_BE_SAVED, null);
}
Does anyone have an idea of what is wrong ?
1 Answer 1
Finally, the answer is to use AdminSite class from com.esri.aims.admincore package.
Replace :
if (!site.save(connectorProxy)) {
throw new BusinessException(AdminErrorMessage.SERVICE_CONFIG_CANT_BE_SAVED, null);
}
by
AdminSite as = new AdminSite("http://" + arcimsHost, alias, login, password);
if (!as.saveSite()){
throw new BusinessException(AdminErrorMessage.SERVICE_CONFIG_CANT_BE_SAVED, null);
}