// Get the descriptor from the existing application module
DeploymentInfoWorkingCopy workingCopy = appModule.resolveDeploymentInfoWorkingCopy(monitor);
workingCopy.setUris(uris);
workingCopy.save();
IServer server = cloudServer.getServer();
final IModule[] modules = ServerUtil.getModules(project);
if (modules != null && modules.length == 1) {
IModule[] add = null;
if (!ServerUtil.containsModule(server, modules[0], monitor)) {
add = new IModule[] { modules[0] };
}
else {
// Delete them first
IServerWorkingCopy wc = server.createWorkingCopy();
wc.modifyModules(null, modules, monitor);
wc.save(true, null);
cloudServer.getBehaviour().refreshModules(monitor);
new WaitWithProgressJob(5, 1000) {
@Override
protected boolean internalRunInWait(IProgressMonitor monitor) throws CoreException {
boolean found = cloudServer.getExistingCloudModule(modules[0]) != null;
if (found) {
cloudServer.getBehaviour().refreshModules(monitor);
}
// If the app has been found, try again until it
// is not found
return !found;
}
}.run(monitor);
// Create new ones
IModule[] newModules = ServerUtil.getModules(project);
if (newModules != null && newModules.length == 1) {
add = new IModule[] { newModules[0] };
}
}
if (add != null && add.length > 0) {
IServerWorkingCopy wc = server.createWorkingCopy();
wc = server.createWorkingCopy();
IStatus status = wc.canModifyModules(add, null, null);
if (status.getSeverity() != IStatus.ERROR) {
CloudFoundryPlugin.getModuleCache().getData(wc.getOriginal())
.tagForAutomaticRepublish(new RepublishModule(add[0], appModule.getDeploymentInfo()));