entries.add(createWarningRefactoringStatusEntry("Unable to test deploy for project '"
+ refactorModel.getProject().getName() + "' - project is not online enabled"));
return entries;
}
ProjectPackageList projectPackageList = refactorModel.getProjectPackageList();
if (Utils.isEmpty(projectPackageList)) {
logger.error("Unable to perform server delete - project package list is null");
entries.add(createFatalRefactoringStatusEntry("Cannot perform delete - project package list is null"));
return entries;
}
if (logger.isDebugEnabled()) {
logger.debug("Deleting the following from server (excluding package.xml(s)):\n"
+ projectPackageList.getAllComponents().toStringLite());
}
monitorCheck(monitor);
// ensure that each project package has a delete manifest
for (ProjectPackage projectPackage : projectPackageList) {
if (projectPackage.getDeleteManifest() == null) {
try {
ContainerDelegate.getInstance().getServiceLocator().getProjectService().getPackageManifestFactory().attachDeleteManifest(projectPackage, true);
} catch (Exception e) {
logger.error("Unable to perform delete - destructive manifest is missing or cannot be "
+ "generated for package '" + projectPackage.getName() + "'", e);
entries
.add(createFatalRefactoringStatusEntry("Unable to perform delete - destructive manifest is missing or cannot be "
+ "generated for package '" + projectPackage.getName() + "': " + e.getMessage()));
return entries;
}
// and if it's STILL null, abort
if (projectPackage.getDeleteManifest() == null) {
logger.error("Unable to perform delete - destructive manifest is missing or cannot be "
+ "generated for package '" + projectPackage.getName() + "'");
entries
.add(createFatalRefactoringStatusEntry("Unable to perform delete - destructive manifest is missing or cannot be "
+ "generated for package '" + projectPackage.getName() + "'"));
return entries;
}
}
}
// test delete, if we have any issues deleting, prompt the user to see if she wants to continue with only deleting locally
testDeploy(monitor);
boolean continueDelete = projectPackageList.hasComponents(false);
if (!continueDelete) {
logger.warn("No delete components found.- discontinuing remote delete");
return entries;
}
// perform sdelete!!
monitorCheck(monitor);
DeployResultExt deployResultExt = null;
try {
deployResultExt = ContainerDelegate.getInstance().getServiceLocator().getPackageDeployService().deployDelete(projectPackageList, false, monitor);
// as part of delete deploy, ide request with auto update package and retrieve for getting updated package.xml
ContainerDelegate.getInstance().getServiceLocator().getProjectService().handleRetrieveResult(projectPackageList, deployResultExt.getRetrieveResultHandler(), true, monitor);
} catch (ServiceTimeoutException ex) {
deployResultExt =
ContainerDelegate.getInstance().getServiceLocator().getPackageDeployService().handleDeployServiceTimeoutException(ex, "remote delete", monitor);
} catch (CoreException e) {
logger.error("Unable to handle retrieve result from delete deploy ", e);
throw new InvocationTargetException(e);
} catch (IOException e) {
logger.error("Unable to handle retrieve result from delete deploy ", e);
throw new InvocationTargetException(e);
}
if (!deployResultExt.isSuccess()) {
deployResultExt.getMessageHandler().sort(DeployMessageExt.SORT_RESULT);
DeployMessage[] messages = deployResultExt.getMessageHandler().getMessages();
StringBuffer strBuff = new StringBuffer();
strBuff.append("Remote delete failed with the following message. Will only delete locally.");
for (DeployMessage deployMessage : messages) {
strBuff.append("\n ").append(deployMessage.getFullName()).append(": ").append(
deployMessage.getProblem());
}
logger.error(strBuff.toString());
entries.add(createWarningRefactoringStatusEntry(strBuff.toString()));
} else {
entries.add(createInfoRefactoringStatusEntry("Resources successfully deleted on server"));
try {
postDeleteProcess(projectPackageList, monitor);
} catch (InvocationTargetException e) {
logger.warn("Unable to update cache with with deleted component(s)", e);
}
clearCaches(projectPackageList);
}
// set to skip builder since new component is validated/compiled during deploy()
try {
ContainerDelegate.getInstance().getServiceLocator().getProjectService().flagSkipBuilder(projectPackageList.getProject());
} catch (CoreException e) {
String logMessage = Utils.generateCoreExceptionLog(e);
logger.warn("Unable to set builder skip flag: " + logMessage, e);
}