boolean canFinish = true;
TaskStatus taskStatus = _taskStatusMap.get(RUNTIME_STARTED_TASK);
// runtime started
try {
if (TomcatUtils.getInstance().isRunning(_runtime)) {
taskStatus.setSeverity(TaskStatus.OK);
taskStatus.setMessage("running");
//taskStatus.setSeverityLabel("started");
} else {
taskStatus.setSeverity(TaskStatus.ERROR);
taskStatus.setMessage("Local runtime must be started to perform a web application export.");
//taskStatus.setSeverityLabel("not started");
canFinish = false;
}
}
catch (Exception e) {
taskStatus.setSeverity(TaskStatus.ERROR);
taskStatus.setMessage("Unable to check if local runtime is started.");
taskStatus.setException(e);
return;
} finally {
_multiTaskStatusControl.update(taskStatus);
}
taskStatus = _taskStatusMap.get(CONNECTION_TASK);
// connect to server
try {
_server.connectToServer();
taskStatus.setSeverity(TaskStatus.OK);
taskStatus.setMessage("OK");
//taskStatus.setSeverityLabel("established");
}
catch (Exception e) {
taskStatus.setSeverity(TaskStatus.ERROR);
taskStatus.setMessage("Connection to server failed.");
taskStatus.setException(e);
return;
} finally {
_multiTaskStatusControl.update(taskStatus);
}
// check version
taskStatus = _taskStatusMap.get(REMOTE_VERSION_TASK);
// connect to server
try {
Version remoteWGAVersion = _server.getServices().getWGAVersion(_server.getSession());
if (remoteWGAVersion.isAtLeast(5, 3)) {
taskStatus.setSeverity(TaskStatus.OK);
taskStatus.setMessage("OK");
} else {
taskStatus.setSeverity(TaskStatus.ERROR);
taskStatus.setMessage("Version of remote server is too low ('" + remoteWGAVersion.getMajorVersion() + "." + remoteWGAVersion.getMinorVersion()+ "')");
taskStatus.setSeverityLabel("too low ('" + remoteWGAVersion.getMajorVersion() + "." + remoteWGAVersion.getMinorVersion()+ "')");
canFinish = false;
}
}
catch (Exception e) {
taskStatus.setSeverity(TaskStatus.ERROR);
taskStatus.setMessage("Version of remote server could not be retrieved. Properly a too low OpenWGA version is installed on the remote server.");
taskStatus.setSeverityLabel("too low");
taskStatus.setException(e);
canFinish = false;
} finally {
_multiTaskStatusControl.update(taskStatus);
}
// retrieve config
taskStatus = _taskStatusMap.get(CONFIGURATION_TASK);
_config = null;
try {
DataSource source = _server.getServices().getWGAConfiguration(_server.getSession());
_config = WGAConfiguration.read(source.getInputStream());
taskStatus.setSeverity(TaskStatus.OK);
taskStatus.setMessage("OK");
//taskStatus.setSeverityLabel("retrieved");
_multiTaskStatusControl.update(taskStatus);
}
catch (Exception e) {
taskStatus.setSeverity(TaskStatus.ERROR);
taskStatus.setMessage("Unable to retrieve WGA configuration.");
taskStatus.setException(e);
return;
} finally {
_multiTaskStatusControl.update(taskStatus);
}
taskStatus = _taskStatusMap.get(WEBAPP_TASK);
try {
// check duplicate webapp
if (_config.getContentStore(_webApplication.toLowerCase()) == null) {
taskStatus.setSeverity(TaskStatus.OK);
taskStatus.setMessage("OK");
} else {
taskStatus.setSeverity(TaskStatus.ERROR);
taskStatus.setMessage("Web application '" + _webApplication + "' already exists on this server.");
//taskStatus.setSeverityLabel("duplicate");
canFinish = false;
}
}
catch (Exception e) {
taskStatus.setSeverity(TaskStatus.ERROR);
taskStatus.setMessage("Error occured during config check.");
taskStatus.setException(e);
} finally {
_multiTaskStatusControl.update(taskStatus);
}
// check domain
taskStatus = _taskStatusMap.get(DOMAIN_TASK);
try {
// retrieve local domain
WGAConfiguration localConfig = _runtime.retrieveWGAConfig(false);
ContentStore localCS = localConfig.getContentStore(_webApplication.toLowerCase());
String localDomainUID = localCS.getDomain();
Domain localDomain = localConfig.getDomain(localDomainUID);
boolean hasDomain = false;
for (Domain remoteDomain : _config.getDomains()) {
if (remoteDomain.getName().equals(localDomain.getName())) {
hasDomain = true;
}
}
if (hasDomain) {
taskStatus.setSeverity(TaskStatus.OK);
taskStatus.setMessage("OK");
//taskStatus.setSeverityLabel("exists");
} else {
taskStatus.setSeverity(TaskStatus.ERROR);
taskStatus.setMessage("Domain '" + localDomain.getName() + "' does not exist on server.");
//taskStatus.setSeverityLabel("missing");
canFinish = false;
}
}
catch (Exception e) {
taskStatus.setSeverity(TaskStatus.ERROR);
taskStatus.setMessage("Error occured during config check.");
taskStatus.setException(e);
} finally {
_multiTaskStatusControl.update(taskStatus);
}
// retrieve content store providing db servers
taskStatus = _taskStatusMap.get(DBSERVER_TASK);
try {
List<DatabaseServerInfo> dbServers = _server.getServices().retrieveContentStoreDatabaseServers(_server.getSession());
// filter servers
_filteredServers = new ArrayList<DatabaseServerInfo>();
for(DatabaseServerInfo info : dbServers) {
if (!info.getCreateableContentStoreImplemenations().isEmpty()) {
_filteredServers.add(info);
}
}
if (!_filteredServers.isEmpty()) {
taskStatus.setSeverity(TaskStatus.OK);
taskStatus.setMessage("OK");
//taskStatus.setSeverityLabel("retrieved");
} else {
taskStatus.setSeverity(TaskStatus.ERROR);
taskStatus.setMessage("No database server available on remote location for web application export.");
//taskStatus.setSeverityLabel("retrieved but empty");
canFinish = false;
}
}
catch (Exception e) {
taskStatus.setSeverity(TaskStatus.ERROR);
taskStatus.setMessage("Error occured during db server retrieval.");
taskStatus.setException(e);
} finally {
_multiTaskStatusControl.update(taskStatus);
}
ExportWGAApplication wizard = (ExportWGAApplication)getWizard();