Author: adietish
Date: 2011-06-07 17:36:55 -0400 (Tue, 07 Jun 2011)
New Revision: 31888
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/AltMethodZippedJSTPublisher.java
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/SingleFileZippedDeploymentIntegrationTest.java
Log:
[JBIDE-9091] testing now if a folder with the same name already exists. removing the
folder if it's present
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/AltMethodZippedJSTPublisher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/AltMethodZippedJSTPublisher.java 2011-06-07
21:35:59 UTC (rev 31887)
+++
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/AltMethodZippedJSTPublisher.java 2011-06-07
21:36:55 UTC (rev 31888)
@@ -12,6 +12,8 @@
******************************************************************************/
package org.jboss.ide.eclipse.archives.webtools.modules;
+import java.io.File;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -82,13 +84,18 @@
String name = sourcePath.lastSegment();
IStatus result = null;
-
- /*
- * always completely remove prior deployment (prior deployfailed marker, deployed
folder etc.)
- * this is needed since we might have switched from exploded to war
- */
- result = removeRemoteDeployment(sourcePath, destination.removeLastSegments(1), name,
monitor);
- if( publishType != IJBossServerPublisher.REMOVE_PUBLISH){
+ DeploymentMarkerUtils.removeDeployFailedMarker(method, server, destination, monitor);
+
+ if(publishType == IJBossServerPublisher.REMOVE_PUBLISH) {
+ result = removeRemoteDeployment(sourcePath, destination.removeLastSegments(1), name,
monitor);
+ } else if (publishType != IJBossServerPublisher.NO_PUBLISH) {
+ /*
+ * remove prior exploded deployment (prior deployfailed marker, deployed folder
etc.)
+ * and redeploy
+ */
+ if (isDeployedExploded(destination)) {
+ removeRemoteDeployment(sourcePath, destination.removeLastSegments(1), name,
monitor);
+ }
// Locally zip it up into the remote tmp folder
result = super.publishModule(method, server, module, publishType, delta,
AbstractServerToolsPublisher.getSubMon(monitor, 50));
@@ -96,7 +103,7 @@
result = remoteFullPublish(sourcePath, destination.removeLastSegments(1), name,
AbstractServerToolsPublisher.getSubMon(monitor, 150));
}
- }
+ }
if( result == null ) {
result = Status.OK_STATUS;
@@ -107,6 +114,13 @@
monitor.done();
}
}
+
+ private boolean isDeployedExploded(IPath destination) {
+ File file = destination.toFile();
+ return file != null
+ && file.exists()
+ && file.isDirectory();
+ }
private IStatus remoteFullPublish(IPath sourcePath,
IPath destFolder, String name, IProgressMonitor monitor) {
@@ -123,7 +137,7 @@
}
return Status.OK_STATUS;
}
-
+
private IStatus removeRemoteDeployment( IPath sourcePath,
IPath destFolder, String name, IProgressMonitor monitor) throws CoreException {
try {
@@ -136,7 +150,7 @@
return ce.getStatus();
}
}
-
+
/**
* Removes the resource with the given name from the given parent folder. Either files
or folders are removed.
* @param sourcePath
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/SingleFileZippedDeploymentIntegrationTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/SingleFileZippedDeploymentIntegrationTest.java 2011-06-07
21:35:59 UTC (rev 31887)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/SingleFileZippedDeploymentIntegrationTest.java 2011-06-07
21:36:55 UTC (rev 31888)
@@ -50,8 +50,7 @@
int changed = MockPublishMethod.getChanged().length;
int removed = MockPublishMethod.getRemoved().length;
assertEquals(2,changed);
- // always removing the prior deployment since we could be switching from exploded to
war
- assertEquals(2,removed);
+ assertEquals(1,removed);
MockPublishMethod.reset();
// make workspace change, repeat
@@ -62,8 +61,7 @@
changed = MockPublishMethod.getChanged().length;
removed = MockPublishMethod.getRemoved().length;
assertEquals(2,changed);
- // always removing the prior deployment since we could be switching from exploded to
war
- assertEquals(2,removed);
+ assertEquals(1,removed);
MockPublishMethod.reset();
server = ServerRuntimeUtils.removeModule(server, mods[0]);
@@ -72,8 +70,8 @@
changed = MockPublishMethod.getChanged().length;
removed = MockPublishMethod.getRemoved().length;
assertEquals(0,changed);
- // removing deployment + .deployed marker
- assertEquals(2,removed);
+ // removing deployment + .deployed + .failed marker
+ assertEquals(3,removed);
MockPublishMethod.reset();
}