IPath remotePathObj = resource.getLocation();
int count = remotePathObj.matchingFirstSegments(_runtime.getDesignRoot().getLocation());
remotePathObj = remotePathObj.removeFirstSegments(count);
String remotePath = remotePathObj.toString();
if (resource.getType() == IResource.FILE) {
DataSource content = new FileDataSource(((IFile) resource).getLocation().toFile());
try {
_remoteServer.getServices().updateFSDesignResource(_remoteServer.getSession(), remotePath, content, resource.getLocalTimeStamp());
}
catch (WGAServiceException e) {
throw new CoreException(new Status(IStatus.ERROR, WGADesignerPlugin.PLUGIN_ID, "Creating design file failed.", e));
}
}
else if (resource.getType() == IResource.FOLDER) {
try {
_remoteServer.getServices().mkFSDesignDir(_remoteServer.getSession(), remotePath);
}
catch (WGAServiceException e) {
throw new CoreException(new Status(IStatus.ERROR, WGADesignerPlugin.PLUGIN_ID, "Creating design folder failed.", e));
}
}
return true;
}
});
monitor.worked(1);
monitor.setTaskName("configuring content store");
WGAConfiguration localConfig = _runtime.retrieveWGAConfig(false);
ContentStore cs = localConfig.getContentStore(_webApplication);
cs.getDatabaseOptions().put(CS_PATH_OPTION_NAME, _remoteDatabaseName);
cs.setDbServer(_remoteDatabaseServer.getUid());
cs.setImplClassName(_remoteDatabaseServer.getCreateableContentStoreImplemenations().get(0));
String remoteDomainUID = null;
if (cs.getDomain().equals("default")) {
remoteDomainUID = "default";
} else {
String localDomainName = localConfig.getDomain(cs.getDomain()).getName();
remoteDomainUID = getDomainUID(_remoteWGAConfiguration, localDomainName);
}
cs.setDomain(remoteDomainUID);
_remoteWGAConfiguration.add(cs);
monitor.worked(1);
monitor.setTaskName("updating remote server configuration");
ByteArrayOutputStream out = new ByteArrayOutputStream();
WGAConfiguration.write(_remoteWGAConfiguration, out);
DataSource configDataSource = new ByteArrayDataSource(out.toByteArray(), "WGAConfiguration", "text/xml");
_remoteServer.getServices().updateWGAConfiguration(_remoteServer.getSession(), configDataSource);
monitor.worked(1);
monitor.setTaskName("waiting for remote content store to get available");
List<String> dbkeys = new ArrayList<String>();
long startTime = System.currentTimeMillis();
while (!dbkeys.contains(_webApplication)) {
if ((System.currentTimeMillis() - startTime) > 1000 * 60) {
throw new TimeoutException("Timeout waiting for remote content store.");
}
Thread.sleep(2000);
dbkeys = _remoteServer.getServices().getConnectedContentDatabases(_remoteServer.getSession());
}
monitor.worked(1);
if (isCopyContent()) {
// create local database dump
monitor.setTaskName("creating content store dump");
WGARemoteServer server = new WGARemoteServer("local", _runtime.getRootURL(), "unused", "unused");
server.connectToServer(5*1000, 0);
DataSource csDump = server.getServices().createContentStoreDump(server.getSession(), _webApplication, isIncludeACL(), true);
monitor.worked(1);
// import dump on remote db
monitor.setTaskName("importing content store dump in remote database");
_remoteServer.getServices().importContentStoreDump(_remoteServer.getSession(), csDump, _webApplication, isIncludeACL(), true);