1

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 ?

R.K.
17.5k3 gold badges61 silver badges110 bronze badges
asked Dec 11, 2012 at 10:34

1 Answer 1

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);
}
answered Jan 8, 2013 at 17:32

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.