Author: rob.stryker(a)jboss.com
Date: 2011-07-13 04:49:20 -0400 (Wed, 13 Jul 2011)
New Revision: 32881
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/AbstractServerToolsPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSERemotePublishHandler.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/MockPublishMethod.java
Log:
JBIDE-9112 - force a full publish attempt after such a property change.
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/AbstractServerToolsPublisher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/AbstractServerToolsPublisher.java 2011-07-13
08:14:54 UTC (rev 32880)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/AbstractServerToolsPublisher.java 2011-07-13
08:49:20 UTC (rev 32881)
@@ -61,7 +61,8 @@
IDeployableServer ds = ServerConverter.getDeployableServer(server);
if( ds == null )
return false;
- if( ServerModelUtilities.isBinaryModule(module[module.length-1]))
+ // If this is a root module (not nested) and is binary, let this publisher handle it
+ if( module.length == 1 &&
ServerModelUtilities.isBinaryModule(module[module.length-1]))
return true;
return !ds.zipsWTPDeployments();
}
@@ -208,30 +209,7 @@
} else if( isBinaryObject )
list.addAll(Arrays.asList(copyBinaryModule(moduleTree, getSubMon(monitor, 700))));
else {
- // A child that must be zipped, forceZip is true
- IPath deployRoot = JBossServerCorePlugin.getServerStateLocation(server.getServer()).
- append(IJBossToolingConstants.TEMP_DEPLOY).makeAbsolute();
-
- try {
- // Make local jar copy
- File temp = File.createTempFile(module.getName(), ".tmp",
deployRoot.toFile()); //$NON-NLS-1$
- IPath tempFile = new Path(temp.getAbsolutePath());
- list.addAll(Arrays.asList(PublishUtil.packModuleIntoJar(moduleTree[moduleTree.length-1],
tempFile)));
-
- // TODO !!!!! Transfer it
- IPath deployPathInner = getParentDeployPath(moduleTree,
server).removeLastSegments(1);
- IPublishCopyCallbackHandler handler =
getCallbackHandler(getRootPath(deployPathInner).append(deployPathInner));
- IPath filePath = deployPath.removeFirstSegments(deployPathInner.segments().length);
- IPath parentFolderPath = filePath.removeLastSegments(1);
- handler.makeDirectoryIfRequired(parentFolderPath, getSubMon(monitor, 200));
- ModuleFile mf = new ModuleFile(tempFile.toFile(), tempFile.lastSegment(), tempFile);
- handler.copyFile(mf, filePath, getSubMon(monitor, 500));
-
- // Cleanup
- tempFile.toFile().delete();
- } catch( IOException ioe) {
- list.add(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, ioe.getMessage(),
ioe));
- }
+ list.addAll(Arrays.asList(transferForceZippedChild(deployPath, module, moduleTree,
monitor)));
}
monitor.done();
@@ -243,7 +221,36 @@
NLS.bind(Messages.ModulePublished, module.getName()), null);
return status;
}
+
+ protected IStatus[] transferForceZippedChild(IPath deployPath, IModule module, IModule[]
moduleTree, IProgressMonitor monitor) throws CoreException {
+ // A child that must be zipped, forceZip is true
+ ArrayList<IStatus> list = new ArrayList<IStatus>();
+ IPath deployRoot = JBossServerCorePlugin.getServerStateLocation(server.getServer()).
+ append(IJBossToolingConstants.TEMP_DEPLOY).makeAbsolute();
+ try {
+ // Make local jar copy
+ File temp = File.createTempFile(module.getName(), ".tmp",
deployRoot.toFile()); //$NON-NLS-1$
+ IPath tempFile = new Path(temp.getAbsolutePath());
+ list.addAll(Arrays.asList(PublishUtil.packModuleIntoJar(moduleTree[moduleTree.length-1],
tempFile)));
+
+ // TODO !!!!! Transfer it
+ IPath deployPathInner = getParentDeployPath(moduleTree,
server).removeLastSegments(1);
+ IPublishCopyCallbackHandler handler =
getCallbackHandler(getRootPath(deployPathInner).append(deployPathInner));
+ IPath filePath = deployPath.removeFirstSegments(deployPathInner.segments().length);
+ IPath parentFolderPath = filePath.removeLastSegments(1);
+ handler.makeDirectoryIfRequired(parentFolderPath, getSubMon(monitor, 200));
+ ModuleFile mf = new ModuleFile(tempFile.toFile(), tempFile.lastSegment(), tempFile);
+ handler.copyFile(mf, filePath, getSubMon(monitor, 500));
+
+ // Cleanup
+ tempFile.toFile().delete();
+ } catch( IOException ioe) {
+ list.add( new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, ioe.getMessage(),
ioe));
+ }
+ return list.toArray(new IStatus[list.size()]);
+ }
+
// TODO consider moving to utility class?
public static Path getRootPath(IPath deployPath) {
String root = (deployPath.getDevice() == null ? "" : deployPath.getDevice())
+ "/"; //$NON-NLS-1$//$NON-NLS-2$
@@ -252,10 +259,17 @@
protected IStatus incrementalPublish(IModule[] moduleTree, IModule module,
IProgressMonitor monitor) throws CoreException {
- monitor.beginTask("Incremental Publish: " +
moduleTree[moduleTree.length-1].getName(), 100); //$NON-NLS-1$
IStatus[] results = new IStatus[] {};
IPath deployPath = getDeployPath(moduleTree, server);
+ IPublishCopyCallbackHandler h1 = getCallbackHandler(deployPath);
+ // quick switch to full publish for JBIDE-9112, recent switch from zip to unzipped
requires full publish
+ if( h1.isFile(new Path("/"), new NullProgressMonitor())) { //$NON-NLS-1$
+ return fullPublish(moduleTree, module, monitor);
+ }
+
+
boolean isBinaryObject = ServerModelUtilities.isBinaryModule(module);
+ monitor.beginTask("Incremental Publish: " +
moduleTree[moduleTree.length-1].getName(), 100); //$NON-NLS-1$
boolean forceZip = forceZipModule(moduleTree);
IPublishCopyCallbackHandler handler = null;
if( !forceZip && !isBinaryObject) {
@@ -266,21 +280,7 @@
results = copyBinaryModule(moduleTree, getSubMon(monitor, 100));
else {
// forceZip a child module
- IPath localDeployRoot =
JBossServerCorePlugin.getServerStateLocation(server.getServer()).
- append(IJBossToolingConstants.TEMP_DEPLOY).makeAbsolute();
- try {
- File temp = File.createTempFile(module.getName(), ".tmp",
localDeployRoot.toFile()); //$NON-NLS-1$
- IPath tempFile = new Path(temp.getAbsolutePath());
- PublishUtil.packModuleIntoJar(moduleTree[moduleTree.length-1], tempFile);
- handler = getCallbackHandler(getRootPath(deployPath));
- String parentFolder = deployPath.removeLastSegments(1).toString();
- handler.makeDirectoryIfRequired(new Path(parentFolder), getSubMon(monitor, 50));
- ModuleFile mf = new ModuleFile(tempFile.toFile(), tempFile.lastSegment(),
tempFile);
- handler.copyFile(mf, deployPath, getSubMon(monitor, 50));
- } catch( IOException ioe) {
- IStatus s = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
ioe.getMessage(), ioe);
- results = new IStatus[] { s };
- }
+ results = transferForceZippedChild(deployPath, module, moduleTree, monitor);
}
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java 2011-07-13
08:14:54 UTC (rev 32880)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java 2011-07-13
08:49:20 UTC (rev 32881)
@@ -74,7 +74,6 @@
*/
public IStatus[] copyFile(IModuleFile mf, IPath path, IProgressMonitor monitor) throws
CoreException;
-
/**
* Delete a directory for this path relative to where the module belongs.
* For example if this path is "/someFolder" you may want to
@@ -86,7 +85,19 @@
*/
public IStatus[] deleteResource(IPath path, IProgressMonitor monitor) throws
CoreException ;
+
/**
+ * Return true if the given path exists and is a file.
+ * Return false if hte given path does not exist, or, is a folder.
+ *
+ * @param path
+ * @param monitor
+ * @return
+ * @throws CoreException
+ */
+ public boolean isFile(IPath path, IProgressMonitor monitor) throws CoreException;
+
+ /**
* Make a directory for this path relative to where the module belongs.
* For example if this path is "/someFolder" you may want to
* make the folder /home/someone/deployfolder/project.war/someFolder
@@ -414,6 +425,12 @@
tmp.setLastModified(new Date().getTime());
return null;
}
+
+ public boolean isFile(IPath path, IProgressMonitor monitor)
+ throws CoreException {
+ File tmp = deployRootFolder.append(path).toFile();
+ return tmp.exists() && tmp.isFile();
+ }
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSERemotePublishHandler.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSERemotePublishHandler.java 2011-07-13
08:14:54 UTC (rev 32880)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSERemotePublishHandler.java 2011-07-13
08:49:20 UTC (rev 32881)
@@ -113,5 +113,18 @@
}
return new IStatus[]{};
}
+
+ public boolean isFile(IPath path, IProgressMonitor monitor)
+ throws CoreException {
+ IPath file = root.append(path);
+ try {
+ IRemoteFile rf = method.getFileServiceSubSystem().getRemoteFileObject(file.toString(),
new NullProgressMonitor());
+ return rf.exists() && rf.isFile();
+ } catch(SystemMessageException sme) {
+ IStatus s = new Status(IStatus.ERROR, RSECorePlugin.PLUGIN_ID,
IEventCodes.JST_PUB_FAIL,
+ "failed to touch remote resource " + file.toString(), sme);
+ throw new CoreException(s);
+ }
+ }
}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/MockPublishMethod.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/MockPublishMethod.java 2011-07-13
08:14:54 UTC (rev 32880)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/MockPublishMethod.java 2011-07-13
08:49:20 UTC (rev 32881)
@@ -108,5 +108,11 @@
changed.add(path2.makeRelative());
return new IStatus[]{};
}
+
+ public boolean isFile(IPath path, IProgressMonitor monitor)
+ throws CoreException {
+ IPath path2 = root.append(path);
+ return path2.toFile().exists() && path2.toFile().isFile();
+ }
}
}