Author: rob.stryker(a)jboss.com
Date: 2011-02-22 18:56:36 -0500 (Tue, 22 Feb 2011)
New Revision: 29283
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/archives/RSEZippedJSTPublisher.java
Log:
JBIDE-8398 to trunk
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/archives/RSEZippedJSTPublisher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/archives/RSEZippedJSTPublisher.java 2011-02-22
23:56:23 UTC (rev 29282)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/archives/RSEZippedJSTPublisher.java 2011-02-22
23:56:36 UTC (rev 29283)
@@ -12,130 +12,32 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.rse.core.archives;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.rse.services.clientserver.messages.SystemElementNotFoundException;
-import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.model.IModuleResourceDelta;
-import org.jboss.ide.eclipse.archives.webtools.modules.WTPZippedPublisher;
-import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-import org.jboss.ide.eclipse.as.core.publishers.AbstractServerToolsPublisher;
-import org.jboss.ide.eclipse.as.core.publishers.PublishUtil;
+import org.jboss.ide.eclipse.as.core.modules.SingleDeployableFactory;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
-import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
-import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethod;
-import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
import org.jboss.ide.eclipse.as.rse.core.RSEPublishMethod;
+import org.jboss.ide.eclipse.as.wtp.core.modules.IJBTModule;
/**
- * This class is in charge of RSE zipped publishing for flexible projects.
- * It extends the functionality of the local zipped publishing class
- * by uploading the file after building it in a temporary directory
+ * This class is in charge of RSE zipped publishing for deployable folders
*/
-public class RSEZippedJSTPublisher extends WTPZippedPublisher {
-
- protected String getPublishMethod() {
- return RSEPublishMethod.RSE_ID;
- }
-
- /**
- * Here we put the deployment first in a temporary remote deploy folder
- * Then during the publishModule call, we'll also upload it to remote machine
- */
- protected String getDeployRoot(IModule[] module, IDeployableServer ds) {
- IPath deployRoot = JBossServerCorePlugin.getServerStateLocation(ds.getServer()).
- append(IJBossServerConstants.TEMP_REMOTE_DEPLOY).makeAbsolute();
- deployRoot.toFile().mkdirs();
- return deployRoot.toString();
- }
-
- @Override
- public IStatus publishModule(
- IJBossServerPublishMethod method,
- IServer server, IModule[] module,
- int publishType, IModuleResourceDelta[] delta,
- IProgressMonitor monitor) throws CoreException {
+public class RSEZippedFolderPublisher extends RSEZippedJSTPublisher {
+ public boolean accepts(String method, IServer server, IModule[] module) {
+ if( !RSEPublishMethod.RSE_ID.equals(method))
+ return false;
- String taskName = "Publishing " + module[0].getName();
- monitor.beginTask(taskName, 200); //$NON-NLS-1$
- monitor.setTaskName(taskName);
- if( module.length > 1 ) {
- monitor.done();
- return null;
+ IDeployableServer ds = ServerConverter.getDeployableServer(server);
+ if( module != null && module.length > 0
+ && module[module.length-1] != null
+ &&
module[module.length-1].getModuleType().getId().equals(SingleDeployableFactory.MODULE_TYPE))
{
+ IModule mod = module[module.length-1];
+ IJBTModule del = (IJBTModule)mod.loadAdapter(IJBTModule.class, new
NullProgressMonitor());
+ if( del != null && !del.isBinary())
+ return ds != null && ds.zipsWTPDeployments();; // we have a folder
}
-
- monitor.setTaskName("Publishing to remote server " + server.getName());
-
- // set up needed vars
- IDeployableServer server2 = ServerConverter.getDeployableServer(server);
- String remoteTempDeployRoot = getDeployRoot(module,
ServerConverter.getDeployableServer(server));
- IPath sourcePath = PublishUtil.getDeployPath(module, remoteTempDeployRoot);
- IModule lastMod = module[module.length-1];
- RSEPublishMethod method2 = (RSEPublishMethod)method;
- IPath destFolder = RSEPublishMethod.findModuleFolderWithDefault(lastMod, server2,
method2.getRemoteRootFolder());
- //IPath tempDestFolder = RSEPublishMethod.findModuleFolderWithDefault(lastMod, server2,
method2.getRemoteTemporaryFolder());
- String name = sourcePath.lastSegment();
- IStatus result = null;
-
-
- // Am I a removal? If yes, remove me, and return
- if( publishType == IJBossServerPublisher.REMOVE_PUBLISH) {
- result = removeRemoteDeployment(method2, sourcePath, destFolder, name, monitor);
- } else {
- // Locally zip it up into the remote tmp folder
- result = super.publishModule(method, server, module, publishType, delta,
- AbstractServerToolsPublisher.getSubMon(monitor, 50));
- if( !result.isOK() ) {
- monitor.done();
- } else {
- result = remoteFullPublish(method, sourcePath, destFolder, name,
- AbstractServerToolsPublisher.getSubMon(monitor, 150));
- }
- }
-
- monitor.done();
- if( result != null ) {
- return result;
- }
-
- return Status.OK_STATUS;
+ return false;
}
-
- private IStatus remoteFullPublish( IJBossServerPublishMethod method, IPath sourcePath,
- IPath destFolder, String name, IProgressMonitor monitor) {
- // Now transfer the file to RSE
- RSEPublishMethod method2 = (RSEPublishMethod)method;
- try {
- method2.getFileService().upload(sourcePath.toFile(), destFolder.toString(), name,
true, null, null,
- AbstractServerToolsPublisher.getSubMon(monitor, 150));
- } catch( SystemElementNotFoundException senfe ) {
- /* Ignore intentionally... file already does not exist on remote server */
- return Status.OK_STATUS;
- } catch( SystemMessageException sme ) {
- return new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, sme.getMessage(),
sme);
- } catch(CoreException ce) {
- return ce.getStatus();
- }
- return Status.OK_STATUS;
- }
-
- private IStatus removeRemoteDeployment( IJBossServerPublishMethod method, IPath
sourcePath,
- IPath destFolder, String name, IProgressMonitor monitor) {
- // Now transfer the file to RSE
- RSEPublishMethod method2 = (RSEPublishMethod)method;
- try {
- method2.getFileService().delete(destFolder.toString(), name, monitor);
- } catch( SystemMessageException sme ) {
- return new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, sme.getMessage(),
sme);
- } catch(CoreException ce) {
- return ce.getStatus();
- }
- return Status.OK_STATUS;
- }
}