JBoss Tools SVN: r18219 - in trunk/portlet/features: org.jboss.tools.portlet.test.feature and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2009-10-21 20:16:19 -0400 (Wed, 21 Oct 2009)
New Revision: 18219
Added:
trunk/portlet/features/org.jboss.tools.portlet.test.feature/.project
trunk/portlet/features/org.jboss.tools.portlet.test.feature/build.properties
trunk/portlet/features/org.jboss.tools.portlet.test.feature/feature.xml
Removed:
trunk/portlet/features/or.jboss.tools.portlet.test.feature/.project
trunk/portlet/features/or.jboss.tools.portlet.test.feature/build.properties
trunk/portlet/features/or.jboss.tools.portlet.test.feature/feature.xml
Log:
fix test feature name for portlet test suite
Deleted: trunk/portlet/features/or.jboss.tools.portlet.test.feature/.project
===================================================================
--- trunk/portlet/features/or.jboss.tools.portlet.test.feature/.project 2009-10-22 00:14:59 UTC (rev 18218)
+++ trunk/portlet/features/or.jboss.tools.portlet.test.feature/.project 2009-10-22 00:16:19 UTC (rev 18219)
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.jboss.tools.portlet.test.feature</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.FeatureBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.FeatureNature</nature>
- </natures>
-</projectDescription>
Deleted: trunk/portlet/features/or.jboss.tools.portlet.test.feature/build.properties
===================================================================
--- trunk/portlet/features/or.jboss.tools.portlet.test.feature/build.properties 2009-10-22 00:14:59 UTC (rev 18218)
+++ trunk/portlet/features/or.jboss.tools.portlet.test.feature/build.properties 2009-10-22 00:16:19 UTC (rev 18219)
@@ -1 +0,0 @@
-bin.includes = feature.xml
Deleted: trunk/portlet/features/or.jboss.tools.portlet.test.feature/feature.xml
===================================================================
--- trunk/portlet/features/or.jboss.tools.portlet.test.feature/feature.xml 2009-10-22 00:14:59 UTC (rev 18218)
+++ trunk/portlet/features/or.jboss.tools.portlet.test.feature/feature.xml 2009-10-22 00:16:19 UTC (rev 18219)
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<feature
- id="org.jboss.tools.portlet.test.feature"
- label="Portlet Test Suite Feature"
- version="1.0.0">
-
- <description url="http://www.example.com/description">
- [Enter Feature Description here.]
- </description>
-
- <copyright url="http://www.example.com/copyright">
- [Enter Copyright Description here.]
- </copyright>
-
- <license url="http://www.example.com/license">
- [Enter License Description here.]
- </license>
-
- <plugin
- id="org.jboss.tools.portlet.core.test"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
-</feature>
Copied: trunk/portlet/features/org.jboss.tools.portlet.test.feature/.project (from rev 18218, trunk/portlet/features/or.jboss.tools.portlet.test.feature/.project)
===================================================================
--- trunk/portlet/features/org.jboss.tools.portlet.test.feature/.project (rev 0)
+++ trunk/portlet/features/org.jboss.tools.portlet.test.feature/.project 2009-10-22 00:16:19 UTC (rev 18219)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.portlet.test.feature</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.pde.FeatureBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.FeatureNature</nature>
+ </natures>
+</projectDescription>
Copied: trunk/portlet/features/org.jboss.tools.portlet.test.feature/build.properties (from rev 18218, trunk/portlet/features/or.jboss.tools.portlet.test.feature/build.properties)
===================================================================
--- trunk/portlet/features/org.jboss.tools.portlet.test.feature/build.properties (rev 0)
+++ trunk/portlet/features/org.jboss.tools.portlet.test.feature/build.properties 2009-10-22 00:16:19 UTC (rev 18219)
@@ -0,0 +1 @@
+bin.includes = feature.xml
Copied: trunk/portlet/features/org.jboss.tools.portlet.test.feature/feature.xml (from rev 18218, trunk/portlet/features/or.jboss.tools.portlet.test.feature/feature.xml)
===================================================================
--- trunk/portlet/features/org.jboss.tools.portlet.test.feature/feature.xml (rev 0)
+++ trunk/portlet/features/org.jboss.tools.portlet.test.feature/feature.xml 2009-10-22 00:16:19 UTC (rev 18219)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="org.jboss.tools.portlet.test.feature"
+ label="Portlet Test Suite Feature"
+ version="1.0.0">
+
+ <description url="http://www.example.com/description">
+ [Enter Feature Description here.]
+ </description>
+
+ <copyright url="http://www.example.com/copyright">
+ [Enter Copyright Description here.]
+ </copyright>
+
+ <license url="http://www.example.com/license">
+ [Enter License Description here.]
+ </license>
+
+ <plugin
+ id="org.jboss.tools.portlet.core.test"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+</feature>
14 years, 8 months
JBoss Tools SVN: r18218 - trunk/portlet/features/or.jboss.tools.portlet.test.feature.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2009-10-21 20:14:59 -0400 (Wed, 21 Oct 2009)
New Revision: 18218
Modified:
trunk/portlet/features/or.jboss.tools.portlet.test.feature/.project
trunk/portlet/features/or.jboss.tools.portlet.test.feature/feature.xml
Log:
fix test feature name for portlet test suite
Modified: trunk/portlet/features/or.jboss.tools.portlet.test.feature/.project
===================================================================
--- trunk/portlet/features/or.jboss.tools.portlet.test.feature/.project 2009-10-21 23:54:38 UTC (rev 18217)
+++ trunk/portlet/features/or.jboss.tools.portlet.test.feature/.project 2009-10-22 00:14:59 UTC (rev 18218)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>or.jboss.tools.portlet.test.feature</name>
+ <name>org.jboss.tools.portlet.test.feature</name>
<comment></comment>
<projects>
</projects>
Modified: trunk/portlet/features/or.jboss.tools.portlet.test.feature/feature.xml
===================================================================
--- trunk/portlet/features/or.jboss.tools.portlet.test.feature/feature.xml 2009-10-21 23:54:38 UTC (rev 18217)
+++ trunk/portlet/features/or.jboss.tools.portlet.test.feature/feature.xml 2009-10-22 00:14:59 UTC (rev 18218)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<feature
- id="or.jboss.tools.portlet.test.feature"
+ id="org.jboss.tools.portlet.test.feature"
label="Portlet Test Suite Feature"
version="1.0.0">
14 years, 8 months
JBoss Tools SVN: r18217 - trunk/portlet/features/or.jboss.tools.portlet.test.feature.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2009-10-21 19:54:38 -0400 (Wed, 21 Oct 2009)
New Revision: 18217
Added:
trunk/portlet/features/or.jboss.tools.portlet.test.feature/.project
trunk/portlet/features/or.jboss.tools.portlet.test.feature/build.properties
trunk/portlet/features/or.jboss.tools.portlet.test.feature/feature.xml
Log:
Share project "or.jboss.tools.portlet.test.feature" into "https://svn.jboss.org/repos/jbosstools"
Added: trunk/portlet/features/or.jboss.tools.portlet.test.feature/.project
===================================================================
--- trunk/portlet/features/or.jboss.tools.portlet.test.feature/.project (rev 0)
+++ trunk/portlet/features/or.jboss.tools.portlet.test.feature/.project 2009-10-21 23:54:38 UTC (rev 18217)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>or.jboss.tools.portlet.test.feature</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.pde.FeatureBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.FeatureNature</nature>
+ </natures>
+</projectDescription>
Property changes on: trunk/portlet/features/or.jboss.tools.portlet.test.feature/.project
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/portlet/features/or.jboss.tools.portlet.test.feature/build.properties
===================================================================
--- trunk/portlet/features/or.jboss.tools.portlet.test.feature/build.properties (rev 0)
+++ trunk/portlet/features/or.jboss.tools.portlet.test.feature/build.properties 2009-10-21 23:54:38 UTC (rev 18217)
@@ -0,0 +1 @@
+bin.includes = feature.xml
Property changes on: trunk/portlet/features/or.jboss.tools.portlet.test.feature/build.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/portlet/features/or.jboss.tools.portlet.test.feature/feature.xml
===================================================================
--- trunk/portlet/features/or.jboss.tools.portlet.test.feature/feature.xml (rev 0)
+++ trunk/portlet/features/or.jboss.tools.portlet.test.feature/feature.xml 2009-10-21 23:54:38 UTC (rev 18217)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="or.jboss.tools.portlet.test.feature"
+ label="Portlet Test Suite Feature"
+ version="1.0.0">
+
+ <description url="http://www.example.com/description">
+ [Enter Feature Description here.]
+ </description>
+
+ <copyright url="http://www.example.com/copyright">
+ [Enter Copyright Description here.]
+ </copyright>
+
+ <license url="http://www.example.com/license">
+ [Enter License Description here.]
+ </license>
+
+ <plugin
+ id="org.jboss.tools.portlet.core.test"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+</feature>
Property changes on: trunk/portlet/features/or.jboss.tools.portlet.test.feature/feature.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 8 months
JBoss Tools SVN: r18215 - in trunk/portlet/tests/org.jboss.tools.portlet.core.test: .settings and 7 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2009-10-21 19:42:27 -0400 (Wed, 21 Oct 2009)
New Revision: 18215
Added:
trunk/portlet/tests/org.jboss.tools.portlet.core.test/.classpath
trunk/portlet/tests/org.jboss.tools.portlet.core.test/.project
trunk/portlet/tests/org.jboss.tools.portlet.core.test/.settings/
trunk/portlet/tests/org.jboss.tools.portlet.core.test/.settings/org.eclipse.jdt.core.prefs
trunk/portlet/tests/org.jboss.tools.portlet.core.test/META-INF/
trunk/portlet/tests/org.jboss.tools.portlet.core.test/META-INF/MANIFEST.MF
trunk/portlet/tests/org.jboss.tools.portlet.core.test/build.properties
trunk/portlet/tests/org.jboss.tools.portlet.core.test/src/
trunk/portlet/tests/org.jboss.tools.portlet.core.test/src/org/
trunk/portlet/tests/org.jboss.tools.portlet.core.test/src/org/jboss/
trunk/portlet/tests/org.jboss.tools.portlet.core.test/src/org/jboss/tools/
trunk/portlet/tests/org.jboss.tools.portlet.core.test/src/org/jboss/tools/portlet/
trunk/portlet/tests/org.jboss.tools.portlet.core.test/src/org/jboss/tools/portlet/core/
trunk/portlet/tests/org.jboss.tools.portlet.core.test/src/org/jboss/tools/portlet/core/PortletCoreTestSuite.java
trunk/portlet/tests/org.jboss.tools.portlet.core.test/src/org/jboss/tools/portlet/core/PortletPluginsLoadTest.java
Log:
Share project "org.jboss.tools.portlet.core.test" into "https://svn.jboss.org/repos/jbosstools"
Added: trunk/portlet/tests/org.jboss.tools.portlet.core.test/.classpath
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.core.test/.classpath (rev 0)
+++ trunk/portlet/tests/org.jboss.tools.portlet.core.test/.classpath 2009-10-21 23:42:27 UTC (rev 18215)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Property changes on: trunk/portlet/tests/org.jboss.tools.portlet.core.test/.classpath
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/portlet/tests/org.jboss.tools.portlet.core.test/.project
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.core.test/.project (rev 0)
+++ trunk/portlet/tests/org.jboss.tools.portlet.core.test/.project 2009-10-21 23:42:27 UTC (rev 18215)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.portlet.core.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Property changes on: trunk/portlet/tests/org.jboss.tools.portlet.core.test/.project
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/portlet/tests/org.jboss.tools.portlet.core.test/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.core.test/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ trunk/portlet/tests/org.jboss.tools.portlet.core.test/.settings/org.eclipse.jdt.core.prefs 2009-10-21 23:42:27 UTC (rev 18215)
@@ -0,0 +1,8 @@
+#Wed Oct 21 16:07:50 PDT 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Property changes on: trunk/portlet/tests/org.jboss.tools.portlet.core.test/.settings/org.eclipse.jdt.core.prefs
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/portlet/tests/org.jboss.tools.portlet.core.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.core.test/META-INF/MANIFEST.MF (rev 0)
+++ trunk/portlet/tests/org.jboss.tools.portlet.core.test/META-INF/MANIFEST.MF 2009-10-21 23:42:27 UTC (rev 18215)
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Portlet Core Test Suite
+Bundle-SymbolicName: org.jboss.tools.portlet.core.test
+Bundle-Version: 1.0.0
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Require-Bundle: org.jboss.tools.tests;bundle-version="2.0.0",
+ org.junit;bundle-version="3.8.2",
+ org.jboss.tools.portlet.core;bundle-version="1.0.0"
Property changes on: trunk/portlet/tests/org.jboss.tools.portlet.core.test/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/portlet/tests/org.jboss.tools.portlet.core.test/build.properties
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.core.test/build.properties (rev 0)
+++ trunk/portlet/tests/org.jboss.tools.portlet.core.test/build.properties 2009-10-21 23:42:27 UTC (rev 18215)
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
Property changes on: trunk/portlet/tests/org.jboss.tools.portlet.core.test/build.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/portlet/tests/org.jboss.tools.portlet.core.test/src/org/jboss/tools/portlet/core/PortletCoreTestSuite.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.core.test/src/org/jboss/tools/portlet/core/PortletCoreTestSuite.java (rev 0)
+++ trunk/portlet/tests/org.jboss.tools.portlet.core.test/src/org/jboss/tools/portlet/core/PortletCoreTestSuite.java 2009-10-21 23:42:27 UTC (rev 18215)
@@ -0,0 +1,12 @@
+package org.jboss.tools.portlet.core;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class PortletCoreTestSuite {
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ suite.addTestSuite(PortletPluginsLoadTest.class);
+ return suite;
+ }
+}
Property changes on: trunk/portlet/tests/org.jboss.tools.portlet.core.test/src/org/jboss/tools/portlet/core/PortletCoreTestSuite.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/portlet/tests/org.jboss.tools.portlet.core.test/src/org/jboss/tools/portlet/core/PortletPluginsLoadTest.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.core.test/src/org/jboss/tools/portlet/core/PortletPluginsLoadTest.java (rev 0)
+++ trunk/portlet/tests/org.jboss.tools.portlet.core.test/src/org/jboss/tools/portlet/core/PortletPluginsLoadTest.java 2009-10-21 23:42:27 UTC (rev 18215)
@@ -0,0 +1,10 @@
+package org.jboss.tools.portlet.core;
+
+import org.jboss.tools.tests.AbstractPluginsLoadTest;
+
+public class PortletPluginsLoadTest extends AbstractPluginsLoadTest {
+
+ public void testPortlrtPlugisAreResolvedAndActivated() {
+ testBundlesAreLoadedFor("org.jboss.tools.portlet.feature");
+ }
+}
Property changes on: trunk/portlet/tests/org.jboss.tools.portlet.core.test/src/org/jboss/tools/portlet/core/PortletPluginsLoadTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 8 months
JBoss Tools SVN: r18211 - in trunk/as/plugins: org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2009-10-21 18:48:20 -0400 (Wed, 21 Oct 2009)
New Revision: 18211
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHSingleFilePublisher.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/plugin.xml
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/DeployAction.java
Log:
JBIDE-5048 - step 3, making single file publisher also work
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/plugin.xml 2009-10-21 19:44:06 UTC (rev 18210)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/plugin.xml 2009-10-21 22:48:20 UTC (rev 18211)
@@ -73,6 +73,11 @@
priority="3"
zipDelegate="false">
</publisher>
+ <publisher
+ class="org.jboss.ide.eclipse.as.ssh.server.SSHSingleFilePublisher"
+ priority="3"
+ zipDelegate="false">
+ </publisher>
</extension>
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHPublisher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHPublisher.java 2009-10-21 19:44:06 UTC (rev 18210)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHPublisher.java 2009-10-21 22:48:20 UTC (rev 18211)
@@ -209,7 +209,7 @@
return PublishUtil.getDeployPath(moduleTree, getRemoteDeployFolder(server.getServer()));
}
- protected static String getRemoteDeployFolder(IServer server) {
+ public static String getRemoteDeployFolder(IServer server) {
return ((Server)server).getAttribute(ISSHDeploymentConstants.DEPLOY_DIRECTORY, (String)null);
}
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHSingleFilePublisher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHSingleFilePublisher.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHSingleFilePublisher.java 2009-10-21 22:48:20 UTC (rev 18211)
@@ -0,0 +1,109 @@
+package org.jboss.ide.eclipse.as.ssh.server;
+
+import java.io.File;
+
+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.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.util.NLS;
+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.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.Messages;
+import org.jboss.ide.eclipse.as.core.extensions.events.IEventCodes;
+import org.jboss.ide.eclipse.as.core.modules.SingleDeployableFactory;
+import org.jboss.ide.eclipse.as.core.modules.SingleDeployableFactory.SingleDeployableModuleDelegate;
+import org.jboss.ide.eclipse.as.core.publishers.PublishUtil;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+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.FileUtil;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.ide.eclipse.as.ssh.server.SSHServerBehaviourDelegate.SSHPublishMethod;
+
+public class SSHSingleFilePublisher implements IJBossServerPublisher {
+
+ public SSHSingleFilePublisher() {
+ }
+
+ public boolean accepts(String method, IServer server, IModule[] module) {
+ if( !method.equals(SSHPublishMethod.SSH_PUBLISH_METHOD))
+ return false;
+ if( module == null )
+ return true;
+ IDeployableServer ds = ServerConverter.getDeployableServer(server);
+ boolean shouldAccept = ds != null
+ && module.length == 1
+ && module[0].getModuleType().getId().equals(SingleDeployableFactory.MODULE_TYPE);
+ return shouldAccept;
+ }
+
+ public int getPublishState() {
+ return IServer.PUBLISH_STATE_NONE;
+ }
+
+ private IDeployableServer server;
+ private SSHPublishMethod publishMethod;
+ private int publishState = IServer.PUBLISH_STATE_NONE;
+ public IStatus publishModule(IJBossServerPublishMethod method,
+ IServer server, IModule[] module, int publishType,
+ IModuleResourceDelta[] delta, IProgressMonitor monitor)
+ throws CoreException {
+ this.server = ServerConverter.getDeployableServer(server);
+ this.publishMethod = (SSHPublishMethod)method;
+ IModule module2 = module[0];
+
+ IStatus status = null;
+ if(publishType == REMOVE_PUBLISH){
+ status = unpublish(this.server, module2, monitor);
+ } else if( publishType == FULL_PUBLISH || publishType == INCREMENTAL_PUBLISH){
+ // if there's no change, do nothing. Otherwise, on change or add, re-publish
+ status = publish(this.server, module2, monitor);
+ }
+ return status;
+ }
+
+ protected IStatus publish(IDeployableServer server, IModule module, IProgressMonitor monitor) {
+ SingleDeployableModuleDelegate delegate = (SingleDeployableModuleDelegate)module.loadAdapter(SingleDeployableModuleDelegate.class, new NullProgressMonitor());
+ if( delegate != null ) {
+ IPath sourcePath = delegate.getGlobalSourcePath();
+ String destFolder = SSHPublisher.getRemoteDeployFolder(server.getServer());
+ IPath destFile = new Path(destFolder).append(sourcePath.lastSegment());
+ try {
+ SSHPublisher.mkdirAndCopy(publishMethod.getSession(), sourcePath.toOSString(), destFile.toString());
+ } catch( CoreException ce ) {
+ return ce.getStatus();
+ }
+ } else {
+ // error can't do nuffin
+ publishState = IServer.PUBLISH_STATE_UNKNOWN;
+ }
+ return Status.OK_STATUS;
+ }
+
+ protected IStatus unpublish(IDeployableServer server, IModule module, IProgressMonitor monitor) throws CoreException {
+ SingleDeployableModuleDelegate delegate = (SingleDeployableModuleDelegate)module.loadAdapter(SingleDeployableModuleDelegate.class, new NullProgressMonitor());
+ if( delegate != null ) {
+ IPath sourcePath = delegate.getGlobalSourcePath();
+ String destFolder = SSHPublisher.getRemoteDeployFolder(server.getServer());
+ IPath destFile = new Path(destFolder).append(sourcePath.lastSegment());
+ SSHZippedJSTPublisher.launchCommand(publishMethod.getSession(), "rm -rf " + destFile.toString());
+ } else {
+ // deleted module. o noes. Ignore it.
+ publishState = IServer.PUBLISH_STATE_UNKNOWN;
+ Status status = new Status(IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID, IEventCodes.SINGLE_FILE_UNPUBLISH_MNF,
+ NLS.bind(Messages.DeleteModuleFail, module.getName()), null);
+ return status;
+ }
+ Status status = new Status(IStatus.OK, JBossServerCorePlugin.PLUGIN_ID, IEventCodes.SINGLE_FILE_UNPUBLISH_SUCCESS,
+ NLS.bind(Messages.ModuleDeleted, module.getName()), null);
+ return status;
+ }
+
+
+}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/DeployAction.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/DeployAction.java 2009-10-21 19:44:06 UTC (rev 18210)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/DeployAction.java 2009-10-21 22:48:20 UTC (rev 18211)
@@ -55,6 +55,7 @@
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.core.internal.PublishServerJob;
import org.eclipse.wst.server.ui.internal.ImageResource;
import org.jboss.ide.eclipse.as.core.modules.SingleDeployableFactory;
import org.jboss.ide.eclipse.as.core.modules.SingleDeployableFactory.UndeployFromServerJob;
@@ -186,8 +187,8 @@
try {
IServerWorkingCopy copy = server.createWorkingCopy();
copy.modifyModules(modules, new IModule[0], new NullProgressMonitor());
- IServer saved = copy.save(false, new NullProgressMonitor());
- saved.publish(IServer.PUBLISH_INCREMENTAL, new NullProgressMonitor());
+ IServer saved = copy.save(false, new NullProgressMonitor());
+ new PublishServerJob(saved).schedule();
} catch( CoreException ce ) {
errorStatus = new Status(IStatus.ERROR, JBossServerUIPlugin.PLUGIN_ID, Messages.ActionDelegatePublishFailed, ce);
errorTitle = Messages.ActionDelegateCannotPublish;
14 years, 8 months
JBoss Tools SVN: r18210 - in trunk/as/plugins: org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2009-10-21 15:44:06 -0400 (Wed, 21 Oct 2009)
New Revision: 18210
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.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.ssh/plugin.xml
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHZippedJSTPublisher.java
Log:
JBIDE-5048 - step 2 - can now handle unziped WTP projects, full, incremental, and remove
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java 2009-10-21 17:11:14 UTC (rev 18209)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java 2009-10-21 19:44:06 UTC (rev 18210)
@@ -12,11 +12,9 @@
import java.io.File;
import java.io.FileFilter;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -29,21 +27,18 @@
import org.eclipse.wst.common.componentcore.ModuleCoreNature;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.model.IModuleFolder;
import org.eclipse.wst.server.core.model.IModuleResource;
import org.eclipse.wst.server.core.model.IModuleResourceDelta;
-import org.eclipse.wst.server.core.util.ProjectModule;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.Messages;
import org.jboss.ide.eclipse.as.core.extensions.events.IEventCodes;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
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.server.xpl.ModulePackager;
import org.jboss.ide.eclipse.as.core.server.xpl.PublishCopyUtil;
+import org.jboss.ide.eclipse.as.core.server.xpl.PublishCopyUtil.LocalCopyCallback;
import org.jboss.ide.eclipse.as.core.util.FileUtil;
import org.jboss.ide.eclipse.as.core.util.IConstants;
-import org.jboss.ide.eclipse.as.core.util.IWTPConstants;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
import org.jboss.ide.eclipse.as.core.util.FileUtil.FileUtilListener;
import org.jboss.ide.eclipse.as.core.util.FileUtil.IFileUtilListener;
@@ -69,7 +64,7 @@
IDeployableServer ds = ServerConverter.getDeployableServer(server);
boolean shouldAccept = ds != null && LocalPublishMethod.LOCAL_PUBLISH_METHOD.equals(type)
&& ModuleCoreNature.isFlexibleProject(module[0].getProject())
- && ds.zipsWTPDeployments();
+ && !ds.zipsWTPDeployments();
return shouldAccept;
}
@@ -116,8 +111,9 @@
list.addAll(Arrays.asList(localSafeDelete(deployPath)));
if( !deployPackaged(moduleTree) && !isBinaryObject(moduleTree)) {
- PublishCopyUtil util = new PublishCopyUtil(server.getServer(), deployPath, tempDeployPath);
- list.addAll(Arrays.asList(util.publishFull(members, deployPath, monitor)));
+ LocalCopyCallback handler = new LocalCopyCallback(server.getServer(), deployPath, tempDeployPath);
+ PublishCopyUtil util = new PublishCopyUtil(handler);
+ list.addAll(Arrays.asList(util.publishFull(members, monitor)));
}
else if( isBinaryObject(moduleTree))
list.addAll(Arrays.asList(copyBinaryModule(moduleTree)));
@@ -154,10 +150,10 @@
IStatus[] results = new IStatus[] {};
IPath deployPath = getDeployPath(moduleTree, server);
IPath tempDeployPath = getTempDeployFolder(moduleTree, server);
- if( !deployPackaged(moduleTree) && !isBinaryObject(moduleTree))
- results = new PublishCopyUtil(server.getServer(), deployPath, tempDeployPath)
- .publishDelta(delta, deployPath, monitor);
- else if( delta.length > 0 ) {
+ if( !deployPackaged(moduleTree) && !isBinaryObject(moduleTree)) {
+ LocalCopyCallback handler = new LocalCopyCallback(server.getServer(), deployPath, tempDeployPath);
+ results = new PublishCopyUtil(handler).publishDelta(delta, monitor);
+ } else if( delta.length > 0 ) {
if( isBinaryObject(moduleTree))
results = copyBinaryModule(moduleTree);
else
@@ -200,12 +196,7 @@
IPath deployPath = getDeployPath(moduleTree, server);
FileUtilListener listener = new FileUtilListener();
IModuleResource[] members = getResources(moduleTree);
- File source = (File)members[0].getAdapter(File.class);
- if( source == null ) {
- IFile ifile = (IFile)members[0].getAdapter(IFile.class);
- if( ifile != null )
- source = ifile.getLocation().toFile();
- }
+ File source = getFile(members[0]);
if( source != null ) {
FileUtil.fileSafeCopy(source, deployPath.toFile(), listener);
return listener.getStatuses();
@@ -251,69 +242,8 @@
FileUtil.safeDelete(deployPath.toFile(), listener);
return (IStatus[]) status.toArray(new IStatus[status.size()]);
}
- public static boolean deployPackaged(IModule[] moduleTree) {
- if( moduleTree[moduleTree.length-1].getModuleType().getId().equals(IWTPConstants.FACET_UTILITY)) return true;
- if( moduleTree[moduleTree.length-1].getModuleType().getId().equals(IWTPConstants.FACET_APP_CLIENT)) return true;
- return false;
- }
public int getPublishState() {
return publishState;
}
-
- /*
- * Just package into a jar raw. Don't think about it, just do it
- */
- protected IStatus[] packModuleIntoJar(IModule module, IPath destination)throws CoreException {
- String dest = destination.toString();
- ModulePackager packager = null;
- try {
- packager = new ModulePackager(dest, false);
- ProjectModule pm = (ProjectModule) module.loadAdapter(ProjectModule.class, null);
- IModuleResource[] resources = pm.members();
- for (int i = 0; i < resources.length; i++) {
- doPackModule(resources[i], packager);
- }
- } catch (IOException e) {
- IStatus status = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, IEventCodes.JST_PUB_ASSEMBLE_FAIL,
- "unable to assemble module " + module.getName(), e); //$NON-NLS-1$
- return new IStatus[]{status};
- }
- finally{
- try{
- if( packager != null )
- packager.finished();
- }
- catch(IOException e){
- IStatus status = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, IEventCodes.JST_PUB_ASSEMBLE_FAIL,
- "unable to assemble module "+ module.getName(), e); //$NON-NLS-1$
- return new IStatus[]{status};
- }
- }
- return new IStatus[]{};
- }
-
-
- /* Add one file or folder to a jar */
- private void doPackModule(IModuleResource resource, ModulePackager packager) throws CoreException, IOException{
- if (resource instanceof IModuleFolder) {
- IModuleFolder mFolder = (IModuleFolder)resource;
- IModuleResource[] resources = mFolder.members();
-
- packager.writeFolder(resource.getModuleRelativePath().append(resource.getName()).toPortableString());
-
- for (int i = 0; resources!= null && i < resources.length; i++) {
- doPackModule(resources[i], packager);
- }
- } else {
- String destination = resource.getModuleRelativePath().append(resource.getName()).toPortableString();
- IFile file = (IFile) resource.getAdapter(IFile.class);
- if (file != null)
- packager.write(file, destination);
- else {
- File file2 = (File) resource.getAdapter(File.class);
- packager.write(file2, destination);
- }
- }
- }
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java 2009-10-21 17:11:14 UTC (rev 18209)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java 2009-10-21 19:44:06 UTC (rev 18210)
@@ -10,11 +10,16 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.core.publishers;
+import java.io.File;
+import java.io.IOException;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jst.server.core.IEnterpriseApplication;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.model.IModuleFile;
@@ -22,10 +27,15 @@
import org.eclipse.wst.server.core.model.IModuleResource;
import org.eclipse.wst.server.core.model.IModuleResourceDelta;
import org.eclipse.wst.server.core.model.ModuleDelegate;
+import org.eclipse.wst.server.core.util.ProjectModule;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.extensions.events.IEventCodes;
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.xpl.ModulePackager;
import org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.ide.eclipse.as.core.util.IWTPConstants;
import org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader.DeploymentModulePrefs;
import org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader.DeploymentPreferences;
import org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader.DeploymentTypePrefs;
@@ -175,9 +185,82 @@
return getResources(tree[tree.length-1]);
}
+ public static File getFile(IModuleResource resource) {
+ File source = (File)resource.getAdapter(File.class);
+ if( source == null ) {
+ IFile ifile = (IFile)resource.getAdapter(IFile.class);
+ if( ifile != null )
+ source = ifile.getLocation().toFile();
+ }
+ return source;
+ }
+
+ public static boolean deployPackaged(IModule[] moduleTree) {
+ if( moduleTree[moduleTree.length-1].getModuleType().getId().equals(IWTPConstants.FACET_UTILITY)) return true;
+ if( moduleTree[moduleTree.length-1].getModuleType().getId().equals(IWTPConstants.FACET_APP_CLIENT)) return true;
+ return false;
+ }
public static java.io.File getFile(IModuleFile mf) {
return (IFile)mf.getAdapter(IFile.class) != null ?
((IFile)mf.getAdapter(IFile.class)).getLocation().toFile() :
(java.io.File)mf.getAdapter(java.io.File.class);
}
+
+
+ /*
+ * Just package into a jar raw. Don't think about it, just do it
+ */
+ public static IStatus[] packModuleIntoJar(IModule module, IPath destination)throws CoreException {
+ String dest = destination.toString();
+ ModulePackager packager = null;
+ try {
+ packager = new ModulePackager(dest, false);
+ ProjectModule pm = (ProjectModule) module.loadAdapter(ProjectModule.class, null);
+ IModuleResource[] resources = pm.members();
+ for (int i = 0; i < resources.length; i++) {
+ doPackModule(resources[i], packager);
+ }
+ } catch (IOException e) {
+ IStatus status = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, IEventCodes.JST_PUB_ASSEMBLE_FAIL,
+ "unable to assemble module " + module.getName(), e); //$NON-NLS-1$
+ return new IStatus[]{status};
+ }
+ finally{
+ try{
+ if( packager != null )
+ packager.finished();
+ }
+ catch(IOException e){
+ IStatus status = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, IEventCodes.JST_PUB_ASSEMBLE_FAIL,
+ "unable to assemble module "+ module.getName(), e); //$NON-NLS-1$
+ return new IStatus[]{status};
+ }
+ }
+ return new IStatus[]{};
+ }
+
+
+ /* Add one file or folder to a jar */
+ public static void doPackModule(IModuleResource resource, ModulePackager packager) throws CoreException, IOException{
+ if (resource instanceof IModuleFolder) {
+ IModuleFolder mFolder = (IModuleFolder)resource;
+ IModuleResource[] resources = mFolder.members();
+
+ packager.writeFolder(resource.getModuleRelativePath().append(resource.getName()).toPortableString());
+
+ for (int i = 0; resources!= null && i < resources.length; i++) {
+ doPackModule(resources[i], packager);
+ }
+ } else {
+ String destination = resource.getModuleRelativePath().append(resource.getName()).toPortableString();
+ IFile file = (IFile) resource.getAdapter(IFile.class);
+ if (file != null)
+ packager.write(file, destination);
+ else {
+ File file2 = (File) resource.getAdapter(File.class);
+ packager.write(file2, destination);
+ }
+ }
+ }
+
}
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 2009-10-21 17:11:14 UTC (rev 18209)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java 2009-10-21 19:44:06 UTC (rev 18210)
@@ -10,7 +10,6 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.core.server.xpl;
-import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -20,10 +19,7 @@
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -31,19 +27,18 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.internal.Messages;
import org.eclipse.wst.server.core.internal.ProgressUtil;
import org.eclipse.wst.server.core.internal.ServerPlugin;
-import org.eclipse.wst.server.core.internal.Trace;
import org.eclipse.wst.server.core.model.IModuleFile;
import org.eclipse.wst.server.core.model.IModuleFolder;
import org.eclipse.wst.server.core.model.IModuleResource;
import org.eclipse.wst.server.core.model.IModuleResourceDelta;
-import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
-import org.jboss.ide.eclipse.as.core.server.internal.ServerAttributeHelper;
+import org.jboss.ide.eclipse.as.core.publishers.PublishUtil;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
/**
* Utility class with an assortment of useful file methods.
@@ -60,301 +55,369 @@
* @since 2.0
*/
public final class PublishCopyUtil {
- // size of the buffer
- private static final int BUFFER = 65536;
-
- // the buffer
- private static byte[] buf = new byte[BUFFER];
-
- private static final IStatus[] EMPTY_STATUS = new IStatus[0];
-
- private static final File tempDir = ServerPlugin.getInstance().getStateLocation().toFile();
+ public interface IPublishCopyCallbackHandler {
+ /**
+ * Copy the file (mf) to a file related to the relative path (path).
+ *
+ * For example if this path is "/someFolder/file.txt" you may want to
+ * copy the file to /home/someone/deployfolder/project.war/someFolder/file.txt
+ *
+ * @param mf
+ * @param path
+ * @param monitor
+ * @return
+ * @throws CoreException
+ */
+ 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
+ * delete the folder /home/someone/deployfolder/project.war/someFolder
+ *
+ * @param dir
+ * @param monitor
+ * @return
+ */
+ public IStatus[] deleteResource(IPath path, IProgressMonitor monitor);
+
+ /**
+ * 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
+ *
+ * @param dir
+ * @param monitor
+ * @return
+ */
+ public IStatus[] makeDirectoryIfRequired(IPath dir, IProgressMonitor monitor);
+ }
- private static final String TEMPFILE_PREFIX = "tmp"; //$NON-NLS-1$
+ public static class LocalCopyCallback implements IPublishCopyCallbackHandler {
- /**
- * PublishUtil cannot be created. Use static methods.
- */
- private IServer server;
- private IPath rootDeploy;
- private IPath rootTmpDeploy;
-
- /**
- *
- * @param server The server we're publishing to
- * @param deploy The deploy path where they're intended to go
- * @param tmpDeploy The temporary location on the same partition
- */
- public PublishCopyUtil(IServer server, IPath deploy, IPath tmpDeploy) {
- this.server = server;
- this.rootDeploy = deploy;
- this.rootTmpDeploy = tmpDeploy;
- }
+ private static final int BUFFER = 65536;
+ private static byte[] buf = new byte[BUFFER];
+ private static final File tempDir = ServerPlugin.getInstance().getStateLocation().toFile();
+ private static final String TEMPFILE_PREFIX = "tmp"; //$NON-NLS-1$
- /**
- * Copy a file from a to b. Closes the input stream after use.
- *
- * @param in an input stream
- * @param to a path to copy to. the directory must already exist
- * @param ts timestamp
- * @throws CoreException if anything goes wrong
- */
- private void copyFile(InputStream in, IPath to, long ts, IModuleFile mf) throws CoreException {
- OutputStream out = null;
+ private IServer server;
+ private IPath deployRootFolder;
+ private IPath tmpDeployRootFolder;
+ public LocalCopyCallback(IServer server, IPath deployFolder, IPath temporaryFolder ) {
+ this.server = server;
+ this.deployRootFolder = deployFolder;
+ this.tmpDeployRootFolder = temporaryFolder;
+ }
- File tempFile = null;
- try {
- File file = to.toFile();
+ public IStatus[] copyFile(IModuleFile mf, IPath relativePath, IProgressMonitor monitor) throws CoreException {
+ //Trace.trace(Trace.PUBLISHING, "Copying: " + mf.getName() + " to " + path.toString());
+ File file = PublishUtil.getFile(mf);
+ if( file != null ) {
+ InputStream in = null;
+ try {
+ in = new FileInputStream(file);
+ } catch (IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0,
+ NLS.bind(Messages.errorReading, file.getAbsolutePath()), e));
+ }
+ copyFile(in, deployRootFolder.append(relativePath), file.lastModified(), mf);
+ } // else silently ignore I guess
+ return new IStatus[]{Status.OK_STATUS};
+ }
+
+ /**
+ * Copy a file from a to b. Closes the input stream after use.
+ *
+ * @param in java.io.InputStream
+ * @param to java.lang.String
+ * @return a status
+ */
+ private IStatus copyFile(InputStream in, String to) {
+ OutputStream out = null;
- // Change from original PublishUtil, will require
- tempFile = File.createTempFile(TEMPFILE_PREFIX, "." + to.getFileExtension(), getTempFolder()); //$NON-NLS-1$
-
- out = new FileOutputStream(tempFile);
-
- int avail = in.read(buf);
- while (avail > 0) {
- out.write(buf, 0, avail);
- avail = in.read(buf);
+ try {
+ out = new FileOutputStream(to);
+
+ int avail = in.read(buf);
+ while (avail > 0) {
+ out.write(buf, 0, avail);
+ avail = in.read(buf);
+ }
+ return Status.OK_STATUS;
+ } catch (Exception e) {
+ //Trace.trace(Trace.SEVERE, "Error copying file", e);
+ return new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCopyingFile, new String[] {to, e.getLocalizedMessage()}), e);
+ } finally {
+ try {
+ if (in != null)
+ in.close();
+ } catch (Exception ex) {
+ // ignore
+ }
+ try {
+ if (out != null)
+ out.close();
+ } catch (Exception ex) {
+ // ignore
+ }
}
+ }
+
+ /**
+ * Copy a file from a to b. Closes the input stream after use.
+ *
+ * @param in an input stream
+ * @param to a path to copy to. the directory must already exist. This must be an absolute path
+ * @param ts timestamp
+ * @throws CoreException if anything goes wrong
+ */
+ private void copyFile(InputStream in, IPath to, long ts, IModuleFile mf) throws CoreException {
+ OutputStream out = null;
- out.close();
- out = null;
-
- moveTempFile(tempFile, file);
-
- if (ts != IResource.NULL_STAMP && ts != 0)
- file.setLastModified(ts);
- } catch (CoreException e) {
- throw e;
- } catch (Exception e) {
- IPath path = mf.getModuleRelativePath().append(mf.getName());
- //Trace.trace(Trace.SEVERE, "Error copying file: " + to.toOSString() + " to " + path.toOSString(), e);
- throw new CoreException(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCopyingFile, path.toOSString(), e.getLocalizedMessage()), null));
- } finally {
- if (tempFile != null && tempFile.exists())
- tempFile.deleteOnExit();
+ File tempFile = null;
try {
- if (in != null)
- in.close();
- } catch (Exception ex) {
- // ignore
+ File file = to.toFile();
+
+ // Change from original PublishUtil, will require
+ tempFile = File.createTempFile(TEMPFILE_PREFIX, "." + to.getFileExtension(), getTempFolder()); //$NON-NLS-1$
+
+ out = new FileOutputStream(tempFile);
+
+ int avail = in.read(buf);
+ while (avail > 0) {
+ out.write(buf, 0, avail);
+ avail = in.read(buf);
+ }
+
+ out.close();
+ out = null;
+
+ moveTempFile(tempFile, file);
+
+ if (ts != IResource.NULL_STAMP && ts != 0)
+ file.setLastModified(ts);
+ } catch (CoreException e) {
+ throw e;
+ } catch (Exception e) {
+ IPath path = mf.getModuleRelativePath().append(mf.getName());
+ //Trace.trace(Trace.SEVERE, "Error copying file: " + to.toOSString() + " to " + path.toOSString(), e);
+ throw new CoreException(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCopyingFile, path.toOSString(), e.getLocalizedMessage()), null));
+ } finally {
+ if (tempFile != null && tempFile.exists())
+ tempFile.deleteOnExit();
+ try {
+ if (in != null)
+ in.close();
+ } catch (Exception ex) {
+ // ignore
+ }
+ try {
+ if (out != null)
+ out.close();
+ } catch (Exception ex) {
+ // ignore
+ }
}
- try {
- if (out != null)
- out.close();
- } catch (Exception ex) {
- // ignore
+ }
+
+ /**
+ * Utility method to move a temp file into position by deleting the original and
+ * swapping in a new copy.
+ *
+ * @param tempFile
+ * @param file
+ * @throws CoreException
+ */
+ private void moveTempFile(File tempFile, File file) throws CoreException {
+ if (file.exists()) {
+ if (!safeDelete(file, 2)) {
+ // attempt to rewrite an existing file with the tempFile contents if
+ // the existing file can't be deleted to permit the move
+ try {
+ InputStream in = new FileInputStream(tempFile);
+ IStatus status = copyFile(in, file.getPath());
+ if (!status.isOK()) {
+ MultiStatus status2 = new MultiStatus(ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorDeleting, file.toString()), null);
+ status2.add(status);
+ throw new CoreException(status2);
+ }
+ return;
+ } catch (FileNotFoundException e) {
+ // shouldn't occur
+ } finally {
+ tempFile.delete();
+ }
+ /*if (!safeDelete(file, 8)) {
+ tempFile.delete();
+ throw new CoreException(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorDeleting, file.toString()), null));
+ }*/
+ }
}
+ if (!safeRename(tempFile, file, 10))
+ throw new CoreException(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorRename, tempFile.toString()), null));
}
- }
-
- /**
- * Utility method to recursively delete a directory.
- *
- * @param dir a directory
- * @param monitor a progress monitor, or <code>null</code> if progress
- * reporting and cancellation are not desired
- * @return a possibly-empty array of error and warning status
- */
- private IStatus[] deleteDirectory(File dir, IProgressMonitor monitor) {
- if (!dir.exists() || !dir.isDirectory())
- return new IStatus[] { new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorNotADirectory, dir.getAbsolutePath()), null) };
- List status = new ArrayList(2);
+ /**
+ * Safe rename. Will try multiple times before giving up.
+ *
+ * @param from
+ * @param to
+ * @param retrys number of times to retry
+ * @return <code>true</code> if it succeeds, <code>false</code> otherwise
+ */
+ private boolean safeRename(File from, File to, int retrys) {
+ // make sure parent dir exists
+ File dir = to.getParentFile();
+ if (dir != null && !dir.exists())
+ dir.mkdirs();
+
+ int count = 0;
+ while (count < retrys) {
+ if (from.renameTo(to))
+ return true;
+
+ count++;
+ // delay if we are going to try again
+ if (count < retrys) {
+ try {
+ Thread.sleep(100);
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+ return false;
+ }
- try {
- File[] files = dir.listFiles();
- int size = files.length;
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(NLS.bind(Messages.deletingTask, new String[] { dir.getAbsolutePath() }), size * 10);
+ protected File getTempFolder() {
+ File f = null;
+ if( tmpDeployRootFolder != null ) {
+ f = tmpDeployRootFolder.toFile();
+ } else if( server != null ){
+ String path = ServerConverter.getDeployableServer(server).getTempDeployFolder();
+ f = new File(path);
+ } else {
+ return tempDir;
+ }
+ if( !f.exists() )
+ f.mkdirs();
+ return f;
+ }
+
+ public IStatus[] deleteResource(IPath resource, IProgressMonitor monitor) {
+ if( resource.toFile().isDirectory())
+ return deleteDirectory(resource.toFile(), monitor);
+ if( !resource.toFile().delete()) {
+ IStatus s = new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorDeleting, resource.toFile().getAbsolutePath()), null);
+ return new IStatus[]{s};
+ }
+ return new IStatus[] { Status.OK_STATUS};
+ }
+
+ /**
+ * Utility method to recursively delete a directory.
+ *
+ * @param dir a directory
+ * @param monitor a progress monitor, or <code>null</code> if progress
+ * reporting and cancellation are not desired
+ * @return a possibly-empty array of error and warning status
+ */
+ private IStatus[] deleteDirectory(File dir, IProgressMonitor monitor) {
+ if (!dir.exists() || !dir.isDirectory())
+ return new IStatus[] { new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorNotADirectory, dir.getAbsolutePath()), null) };
- // cycle through files
- boolean deleteCurrent = true;
- for (int i = 0; i < size; i++) {
- File current = files[i];
- if (current.isFile()) {
- if (!current.delete()) {
- status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorDeleting, files[i].getAbsolutePath()), null));
- deleteCurrent = false;
+ List status = new ArrayList(2);
+
+ try {
+ File[] files = dir.listFiles();
+ int size = files.length;
+ monitor = ProgressUtil.getMonitorFor(monitor);
+ monitor.beginTask(NLS.bind(Messages.deletingTask, new String[] { dir.getAbsolutePath() }), size * 10);
+
+ // cycle through files
+ boolean deleteCurrent = true;
+ for (int i = 0; i < size; i++) {
+ File current = files[i];
+ if (current.isFile()) {
+ if (!current.delete()) {
+ status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorDeleting, files[i].getAbsolutePath()), null));
+ deleteCurrent = false;
+ }
+ monitor.worked(10);
+ } else if (current.isDirectory()) {
+ monitor.subTask(NLS.bind(Messages.deletingTask, new String[] {current.getAbsolutePath()}));
+ IStatus[] stat = deleteDirectory(current, ProgressUtil.getSubMonitorFor(monitor, 10));
+ if (stat != null && stat.length > 0) {
+ deleteCurrent = false;
+ addArrayToList(status, stat);
+ }
}
- monitor.worked(10);
- } else if (current.isDirectory()) {
- monitor.subTask(NLS.bind(Messages.deletingTask, new String[] {current.getAbsolutePath()}));
- IStatus[] stat = deleteDirectory(current, ProgressUtil.getSubMonitorFor(monitor, 10));
- if (stat != null && stat.length > 0) {
- deleteCurrent = false;
- addArrayToList(status, stat);
+ }
+ if (deleteCurrent && !dir.delete())
+ status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorDeleting, dir.getAbsolutePath()), null));
+ monitor.done();
+ } catch (Exception e) {
+ //Trace.trace(Trace.SEVERE, "Error deleting directory " + dir.getAbsolutePath(), e);
+ status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, e.getLocalizedMessage(), null));
+ }
+
+ IStatus[] stat = new IStatus[status.size()];
+ status.toArray(stat);
+ return stat;
+ }
+
+ /**
+ * Safe delete. Tries to delete multiple times before giving up.
+ *
+ * @param f
+ * @return <code>true</code> if it succeeds, <code>false</code> otherwise
+ */
+ private boolean safeDelete(File f, int retrys) {
+ int count = 0;
+ while (count < retrys) {
+ if (!f.exists())
+ return true;
+
+ f.delete();
+
+ if (!f.exists())
+ return true;
+
+ count++;
+ // delay if we are going to try again
+ if (count < retrys) {
+ try {
+ Thread.sleep(100);
+ } catch (Exception e) {
+ // ignore
}
}
}
- if (deleteCurrent && !dir.delete())
- status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorDeleting, dir.getAbsolutePath()), null));
- monitor.done();
- } catch (Exception e) {
- //Trace.trace(Trace.SEVERE, "Error deleting directory " + dir.getAbsolutePath(), e);
- status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, e.getLocalizedMessage(), null));
+ return false;
}
- IStatus[] stat = new IStatus[status.size()];
- status.toArray(stat);
- return stat;
+ public IStatus[] makeDirectoryIfRequired(IPath dir, IProgressMonitor monitor) {
+ dir.toFile().mkdirs();
+ return new IStatus[] {Status.OK_STATUS};
+ }
+
}
- /**
- * Smart copy the given module resources to the given path.
- *
- * Not yet used
- *
- * @param resources an array of module resources
- * @param path an external path to copy to
- * @param monitor a progress monitor, or <code>null</code> if progress
- * reporting and cancellation are not desired
- * @return a possibly-empty array of error and warning status
- */
-// private IStatus[] publishSmart(IModuleResource[] resources, IPath path, IProgressMonitor monitor) {
-// if (resources == null)
-// return EMPTY_STATUS;
-//
-// monitor = ProgressUtil.getMonitorFor(monitor);
-//
-// List status = new ArrayList(2);
-// File toDir = path.toFile();
-// int fromSize = resources.length;
-// String[] fromFileNames = new String[fromSize];
-// for (int i = 0; i < fromSize; i++)
-// fromFileNames[i] = resources[i].getName();
-//
-// // cache files and file names for performance
-// File[] toFiles = null;
-// String[] toFileNames = null;
-//
-// boolean foundExistingDir = false;
-// if (toDir.exists()) {
-// if (toDir.isDirectory()) {
-// foundExistingDir = true;
-// toFiles = toDir.listFiles();
-// int toSize = toFiles.length;
-// toFileNames = new String[toSize];
-//
-// // check if this exact file exists in the new directory
-// for (int i = 0; i < toSize; i++) {
-// toFileNames[i] = toFiles[i].getName();
-// boolean isDir = toFiles[i].isDirectory();
-// boolean found = false;
-// for (int j = 0; j < fromSize; j++) {
-// if (toFileNames[i].equals(fromFileNames[j]) && isDir == resources[j] instanceof IModuleFolder)
-// found = true;
-// }
-//
-// // delete file if it can't be found or isn't the correct type
-// if (!found) {
-// if (isDir) {
-// IStatus[] stat = deleteDirectory(toFiles[i], null);
-// addArrayToList(status, stat);
-// } else {
-// if (!toFiles[i].delete())
-// status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorDeleting, toFiles[i].getAbsolutePath()), null));
-// }
-// toFiles[i] = null;
-// toFileNames[i] = null;
-// }
-// }
-// } else { //if (toDir.isFile())
-// if (!toDir.delete()) {
-// status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorDeleting, toDir.getAbsolutePath()), null));
-// IStatus[] stat = new IStatus[status.size()];
-// status.toArray(stat);
-// return stat;
-// }
-// }
-// }
-// if (!foundExistingDir && !toDir.mkdirs()) {
-// status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorMkdir, toDir.getAbsolutePath()), null));
-// IStatus[] stat = new IStatus[status.size()];
-// status.toArray(stat);
-// return stat;
-// }
-//
-// if (monitor.isCanceled())
-// return new IStatus[] { Status.CANCEL_STATUS };
-//
-// monitor.worked(50);
-//
-// // cycle through files and only copy when it doesn't exist
-// // or is newer
-// if (toFiles == null)
-// toFiles = toDir.listFiles();
-// int toSize = 0;
-// if (toFiles != null)
-// toSize = toFiles.length;
-//
-// int dw = 0;
-// if (toSize > 0)
-// dw = 500 / toSize;
-//
-// // cache file names and last modified dates for performance
-// if (toFileNames == null)
-// toFileNames = new String[toSize];
-// long[] toFileMod = new long[toSize];
-// for (int i = 0; i < toSize; i++) {
-// if (toFiles[i] != null) {
-// if (toFileNames[i] != null)
-// toFileNames[i] = toFiles[i].getName();
-// toFileMod[i] = toFiles[i].lastModified();
-// }
-// }
-//
-// for (int i = 0; i < fromSize; i++) {
-// IModuleResource current = resources[i];
-// String name = fromFileNames[i];
-// boolean currentIsDir = current instanceof IModuleFolder;
-//
-// if (!currentIsDir) {
-// // check if this is a new or newer file
-// boolean copy = true;
-// IModuleFile mf = (IModuleFile) current;
-//
-// long mod = -1;
-// IFile file = (IFile) mf.getAdapter(IFile.class);
-// if (file != null) {
-// mod = file.getLocalTimeStamp();
-// } else {
-// File file2 = (File) mf.getAdapter(File.class);
-// mod = file2.lastModified();
-// }
-//
-// for (int j = 0; j < toSize; j++) {
-// if (name.equals(toFileNames[j]) && mod == toFileMod[j])
-// copy = false;
-// }
-//
-// if (copy) {
-// try {
-// copyFile(mf, path.append(name));
-// } catch (CoreException ce) {
-// status.add(ce.getStatus());
-// }
-// }
-// monitor.worked(dw);
-// } else { //if (currentIsDir) {
-// IModuleFolder folder = (IModuleFolder) current;
-// IModuleResource[] children = folder.members();
-// monitor.subTask(NLS.bind(Messages.copyingTask, new String[] {name, name}));
-// IStatus[] stat = publishSmart(children, path.append(name), ProgressUtil.getSubMonitorFor(monitor, dw));
-// addArrayToList(status, stat);
-// }
-// }
-// if (monitor.isCanceled())
-// return new IStatus[] { Status.CANCEL_STATUS };
-//
-// monitor.worked(500 - dw * toSize);
-// monitor.done();
-//
-// IStatus[] stat = new IStatus[status.size()];
-// status.toArray(stat);
-// return stat;
-// }
+
+
+
+
+
+
+ private static final IStatus[] EMPTY_STATUS = new IStatus[0];
+ private IPublishCopyCallbackHandler handler;
+ public PublishCopyUtil(IPublishCopyCallbackHandler handler) {
+ this.handler = handler;
+ }
+
+
/**
* Handle a delta publish.
*
@@ -364,7 +427,7 @@
* reporting and cancellation are not desired
* @return a possibly-empty array of error and warning status
*/
- public IStatus[] publishDelta(IModuleResourceDelta[] delta, IPath path, IProgressMonitor monitor) {
+ public IStatus[] publishDelta(IModuleResourceDelta[] delta, IProgressMonitor monitor) {
if (delta == null)
return EMPTY_STATUS;
@@ -373,7 +436,7 @@
List status = new ArrayList(2);
int size2 = delta.length;
for (int i = 0; i < size2; i++) {
- IStatus[] stat = publishDelta(delta[i], path, monitor);
+ IStatus[] stat = publishDelta(delta[i], new Path("/"), monitor); //$NON-NLS-1$
addArrayToList(status, stat);
}
@@ -400,15 +463,14 @@
if (resource instanceof IModuleFile) {
IModuleFile file = (IModuleFile) resource;
try {
- if (kind2 == IModuleResourceDelta.REMOVED)
- deleteFile2(path, file);
+ if (kind2 == IModuleResourceDelta.REMOVED) {
+ IPath path2 = path.append(file.getModuleRelativePath()).append(file.getName());
+ handler.deleteResource(path2, monitor);
+ }
else {
IPath path2 = path.append(file.getModuleRelativePath()).append(file.getName());
- File f = path2.toFile().getParentFile();
- if (!f.exists())
- f.mkdirs();
-
- copyFile(file, path2);
+ handler.makeDirectoryIfRequired(path2.removeLastSegments(1), monitor);
+ handler.copyFile(file, path2, monitor);
}
} catch (CoreException ce) {
status.add(ce.getStatus());
@@ -420,12 +482,9 @@
if (kind2 == IModuleResourceDelta.ADDED) {
IPath path2 = path.append(resource.getModuleRelativePath()).append(resource.getName());
- File file = path2.toFile();
- if (!file.exists() && !file.mkdirs()) {
- status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorMkdir, path2), null));
- IStatus[] stat = new IStatus[status.size()];
- status.toArray(stat);
- return stat;
+ IStatus[] s = handler.makeDirectoryIfRequired(path2, monitor);
+ if( s.length > 0 && !s[0].isOK()) {
+ return s;
}
}
@@ -438,8 +497,8 @@
if (kind2 == IModuleResourceDelta.REMOVED) {
IPath path2 = path.append(resource.getModuleRelativePath()).append(resource.getName());
- File file = path2.toFile();
- if (file.exists() && !file.delete()) {
+ IStatus[] stat = handler.deleteResource(path2, monitor);
+ if( stat.length > 0 && !stat[0].isOK()) {
status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorDeleting, path2), null));
}
}
@@ -449,33 +508,7 @@
return stat;
}
- private void deleteFile2(IPath path, IModuleFile file) throws CoreException {
- //Trace.trace(Trace.PUBLISHING, "Deleting: " + file.getName() + " from " + path.toString());
- IPath path2 = path.append(file.getModuleRelativePath()).append(file.getName());
- if (path2.toFile().exists() && !path2.toFile().delete())
- throw new CoreException(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorDeleting, path2), null));
- }
- private void copyFile(IModuleFile mf, IPath path) throws CoreException {
- //Trace.trace(Trace.PUBLISHING, "Copying: " + mf.getName() + " to " + path.toString());
-
- IFile file = (IFile) mf.getAdapter(IFile.class);
- if (file != null)
- copyFile(file.getContents(), path, file.getLocalTimeStamp(), mf);
- else {
- File file2 = (File) mf.getAdapter(File.class);
- if( file2 != null ) {
- InputStream in = null;
- try {
- in = new FileInputStream(file2);
- } catch (IOException e) {
- throw new CoreException(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorReading, file2.getAbsolutePath()), e));
- }
- copyFile(in, path, file2.lastModified(), mf);
- } // else silently ignore I guess
- }
- }
-
/**
* Publish the given module resources to the given path.
*
@@ -485,7 +518,11 @@
* reporting and cancellation are not desired
* @return a possibly-empty array of error and warning status
*/
- public IStatus[] publishFull(IModuleResource[] resources, IPath path, IProgressMonitor monitor) {
+ public IStatus[] publishFull(IModuleResource[] resources, IProgressMonitor monitor) {
+ return publishFull(resources, new Path("/"), monitor); //$NON-NLS-1$
+ }
+
+ public IStatus[] publishFull(IModuleResource[] resources, IPath relative, IProgressMonitor monitor) {
if (resources == null)
return EMPTY_STATUS;
@@ -494,7 +531,7 @@
List status = new ArrayList(2);
int size = resources.length;
for (int i = 0; i < size; i++) {
- IStatus[] stat = copy(resources[i], path, monitor);
+ IStatus[] stat = copy(resources[i], relative, monitor);
addArrayToList(status, stat);
}
@@ -503,7 +540,7 @@
return stat;
}
- private IStatus[] copy(IModuleResource resource, IPath path, IProgressMonitor monitor) {
+ private IStatus[] copy(IModuleResource resource, IPath path, IProgressMonitor monitor) {
String name = resource.getName();
//Trace.trace(Trace.PUBLISHING, "Copying: " + name + " to " + path.toString());
List status = new ArrayList(2);
@@ -514,11 +551,12 @@
} else {
IModuleFile mf = (IModuleFile) resource;
path = path.append(mf.getModuleRelativePath()).append(name);
- File f = path.toFile().getParentFile();
- if (!f.exists())
- f.mkdirs();
+ IStatus[] stats = handler.makeDirectoryIfRequired(path.removeLastSegments(1), monitor);
+ if( stats.length > 0 && !stats[0].isOK())
+ addArrayToList(status, stats);
+
try {
- copyFile(mf, path);
+ addArrayToList(status, handler.copyFile(mf, path, monitor));
} catch (CoreException ce) {
status.add(ce.getStatus());
}
@@ -528,144 +566,7 @@
return stat;
}
- /**
- * Utility method to move a temp file into position by deleting the original and
- * swapping in a new copy.
- *
- * @param tempFile
- * @param file
- * @throws CoreException
- */
- private void moveTempFile(File tempFile, File file) throws CoreException {
- if (file.exists()) {
- if (!safeDelete(file, 2)) {
- // attempt to rewrite an existing file with the tempFile contents if
- // the existing file can't be deleted to permit the move
- try {
- InputStream in = new FileInputStream(tempFile);
- IStatus status = copyFile(in, file.getPath());
- if (!status.isOK()) {
- MultiStatus status2 = new MultiStatus(ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorDeleting, file.toString()), null);
- status2.add(status);
- throw new CoreException(status2);
- }
- return;
- } catch (FileNotFoundException e) {
- // shouldn't occur
- } finally {
- tempFile.delete();
- }
- /*if (!safeDelete(file, 8)) {
- tempFile.delete();
- throw new CoreException(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorDeleting, file.toString()), null));
- }*/
- }
- }
- if (!safeRename(tempFile, file, 10))
- throw new CoreException(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorRename, tempFile.toString()), null));
- }
-
- /**
- * Copy a file from a to b. Closes the input stream after use.
- *
- * @param in java.io.InputStream
- * @param to java.lang.String
- * @return a status
- */
- private IStatus copyFile(InputStream in, String to) {
- OutputStream out = null;
-
- try {
- out = new FileOutputStream(to);
-
- int avail = in.read(buf);
- while (avail > 0) {
- out.write(buf, 0, avail);
- avail = in.read(buf);
- }
- return Status.OK_STATUS;
- } catch (Exception e) {
- //Trace.trace(Trace.SEVERE, "Error copying file", e);
- return new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCopyingFile, new String[] {to, e.getLocalizedMessage()}), e);
- } finally {
- try {
- if (in != null)
- in.close();
- } catch (Exception ex) {
- // ignore
- }
- try {
- if (out != null)
- out.close();
- } catch (Exception ex) {
- // ignore
- }
- }
- }
-
- /**
- * Safe delete. Tries to delete multiple times before giving up.
- *
- * @param f
- * @return <code>true</code> if it succeeds, <code>false</code> otherwise
- */
- private boolean safeDelete(File f, int retrys) {
- int count = 0;
- while (count < retrys) {
- if (!f.exists())
- return true;
-
- f.delete();
-
- if (!f.exists())
- return true;
-
- count++;
- // delay if we are going to try again
- if (count < retrys) {
- try {
- Thread.sleep(100);
- } catch (Exception e) {
- // ignore
- }
- }
- }
- return false;
- }
-
- /**
- * Safe rename. Will try multiple times before giving up.
- *
- * @param from
- * @param to
- * @param retrys number of times to retry
- * @return <code>true</code> if it succeeds, <code>false</code> otherwise
- */
- private boolean safeRename(File from, File to, int retrys) {
- // make sure parent dir exists
- File dir = to.getParentFile();
- if (dir != null && !dir.exists())
- dir.mkdirs();
-
- int count = 0;
- while (count < retrys) {
- if (from.renameTo(to))
- return true;
-
- count++;
- // delay if we are going to try again
- if (count < retrys) {
- try {
- Thread.sleep(100);
- } catch (Exception e) {
- // ignore
- }
- }
- }
- return false;
- }
-
- private void addArrayToList(List list, IStatus[] a) {
+ public static void addArrayToList(List list, IStatus[] a) {
if (list == null || a == null || a.length == 0)
return;
@@ -673,19 +574,4 @@
for (int i = 0; i < size; i++)
list.add(a[i]);
}
-
- protected File getTempFolder() {
- File f = null;
- if( rootTmpDeploy != null ) {
- f = rootTmpDeploy.toFile();
- } else if( server != null ){
- String path = ServerConverter.getDeployableServer(server).getTempDeployFolder();
- f = new File(path);
- } else {
- return tempDir;
- }
- if( !f.exists() )
- f.mkdirs();
- return f;
- }
}
\ No newline at end of file
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/plugin.xml 2009-10-21 17:11:14 UTC (rev 18209)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/plugin.xml 2009-10-21 19:44:06 UTC (rev 18210)
@@ -68,6 +68,11 @@
priority="3"
zipDelegate="true">
</publisher>
+ <publisher
+ class="org.jboss.ide.eclipse.as.ssh.server.SSHPublisher"
+ priority="3"
+ zipDelegate="false">
+ </publisher>
</extension>
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHPublisher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHPublisher.java 2009-10-21 17:11:14 UTC (rev 18209)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHPublisher.java 2009-10-21 19:44:06 UTC (rev 18210)
@@ -1,17 +1,264 @@
package org.jboss.ide.eclipse.as.ssh.server;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
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.MultiStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.common.componentcore.ModuleCoreNature;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.internal.Server;
+import org.eclipse.wst.server.core.model.IModuleFile;
+import org.eclipse.wst.server.core.model.IModuleResource;
+import org.eclipse.wst.server.core.model.IModuleResourceDelta;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.Messages;
+import org.jboss.ide.eclipse.as.core.extensions.events.IEventCodes;
+import org.jboss.ide.eclipse.as.core.publishers.PublishUtil;
+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.server.xpl.PublishCopyUtil;
+import org.jboss.ide.eclipse.as.core.server.xpl.PublishCopyUtil.IPublishCopyCallbackHandler;
+import org.jboss.ide.eclipse.as.core.server.xpl.PublishCopyUtil.LocalCopyCallback;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.ide.eclipse.as.ssh.SSHDeploymentPlugin;
+import org.jboss.ide.eclipse.as.ssh.server.SSHServerBehaviourDelegate.SSHPublishMethod;
-public class SSHPublisher {
- protected void publishStart(IServer server, final IProgressMonitor monitor) throws CoreException {
+import com.jcraft.jsch.Session;
+
+public class SSHPublisher implements IJBossServerPublisher {
+ protected IModuleResourceDelta[] delta;
+ protected IDeployableServer server;
+ protected int publishState = IServer.PUBLISH_STATE_NONE;
+ protected SSHPublishMethod publishMethod;
+
+ public SSHPublisher() {}
+
+ public boolean accepts(String method, IServer server, IModule[] module) {
+ if( !method.equals(SSHPublishMethod.SSH_PUBLISH_METHOD))
+ return false;
+ if( module == null )
+ return true;
+ IDeployableServer ds = ServerConverter.getDeployableServer(server);
+ boolean shouldAccept = ds != null
+ && ModuleCoreNature.isFlexibleProject(module[0].getProject())
+ && !SSHPublishUtil.getZipsSSHDeployments(server);
+ return shouldAccept;
}
+
+ public int getPublishState() {
+ return IServer.PUBLISH_STATE_NONE;
+ }
+
+ public IStatus publishModule(IJBossServerPublishMethod method,
+ IServer server, IModule[] module, int publishType,
+ IModuleResourceDelta[] delta, IProgressMonitor monitor)
+ throws CoreException {
+ IStatus status = null;
+ this.server = ServerConverter.getDeployableServer(server);
+ this.delta = delta;
+ this.publishMethod = (SSHPublishMethod)method;
+
+ boolean deleted = false;
+ for( int i = 0; i < module.length; i++ ) {
+ if( module[i].isExternal() )
+ deleted = true;
+ }
+
+ if (publishType == REMOVE_PUBLISH ) {
+ status = unpublish(this.server, module, monitor);
+ } else {
+ if( deleted ) {
+ publishState = IServer.PUBLISH_STATE_UNKNOWN;
+ } else {
+ if (publishType == FULL_PUBLISH ) {
+ status = fullPublish(module, module[module.length-1], monitor);
+ } else if (publishType == INCREMENTAL_PUBLISH) {
+ status = incrementalPublish(module, module[module.length-1], monitor);
+ }
+ }
+ }
+ return status;
+ }
- protected void publishFinish(IServer server, final IProgressMonitor monitor) throws CoreException {
+ protected IStatus fullPublish(IModule[] moduleTree, IModule module, IProgressMonitor monitor) throws CoreException {
+ IPath remoteDeployPath = getDeployPath(moduleTree, server);
+ IModuleResource[] members = PublishUtil.getResources(module);
+
+ // First delete it
+ // if the module we're publishing is a project, not a binary, clean it's folder
+ if( !(new Path(module.getName()).segmentCount() > 1 ))
+ SSHZippedJSTPublisher.launchCommand(publishMethod.getSession(), "rm -rf " + remoteDeployPath.toString());
+
+ ArrayList<IStatus> list = new ArrayList<IStatus>();
+
+ if( !PublishUtil.deployPackaged(moduleTree) && !PublishUtil.isBinaryObject(moduleTree)) {
+ SSHCopyCallback callback = new SSHCopyCallback(remoteDeployPath);
+ PublishCopyUtil util = new PublishCopyUtil(callback);
+ list.addAll(Arrays.asList(util.publishFull(members, monitor)));
+ }
+ else if( PublishUtil.isBinaryObject(moduleTree))
+ list.addAll(Arrays.asList(copyBinaryModule(moduleTree)));
+ else {
+ IPath deployRoot = JBossServerCorePlugin.getServerStateLocation(server.getServer()).
+ append(IJBossServerConstants.DEPLOY).makeAbsolute();
+ try {
+ File temp = deployRoot.toFile().createTempFile(module.getName(), ".tmp", deployRoot.toFile());
+ IPath tempFile = new Path(temp.getAbsolutePath());
+ list.addAll(Arrays.asList(PublishUtil.packModuleIntoJar(moduleTree[moduleTree.length-1], tempFile)));
+ mkdirAndCopy(publishMethod.getSession(), tempFile.toString(), remoteDeployPath.toString());
+ } catch( IOException ioe) {
+ // TODO error handling
+ }
+ }
+
+ if( list.size() > 0 )
+ return createMultiStatus(list, module);
+ return Status.OK_STATUS;
}
- protected void publishModule(int publishType, IModule[] module, IProgressMonitor monitor) throws CoreException {
+ protected IStatus incrementalPublish(IModule[] moduleTree, IModule module, IProgressMonitor monitor) throws CoreException {
+ IStatus[] results = new IStatus[] {};
+ IPath remoteDeployPath = getDeployPath(moduleTree, server);
+ if( !PublishUtil.deployPackaged(moduleTree) && !PublishUtil.isBinaryObject(moduleTree)) {
+ SSHCopyCallback handler = new SSHCopyCallback(remoteDeployPath);
+ results = new PublishCopyUtil(handler).publishDelta(delta, monitor);
+ } else if( delta.length > 0 ) {
+ if( PublishUtil.isBinaryObject(moduleTree))
+ results = copyBinaryModule(moduleTree);
+ else {
+ IPath localDeployRoot = JBossServerCorePlugin.getServerStateLocation(server.getServer()).
+ append(IJBossServerConstants.DEPLOY).makeAbsolute();
+ try {
+ File temp = localDeployRoot.toFile().createTempFile(module.getName(), ".tmp", localDeployRoot.toFile());
+ IPath tempFile = new Path(temp.getAbsolutePath());
+ PublishUtil.packModuleIntoJar(moduleTree[moduleTree.length-1], tempFile);
+ mkdirAndCopy(publishMethod.getSession(), tempFile.toString(), remoteDeployPath.toString());
+ } catch( IOException ioe) {
+ // TODO error handling
+ }
+ }
+ }
+
+ if( results != null && results.length > 0 ) {
+ MultiStatus ms = new MultiStatus(JBossServerCorePlugin.PLUGIN_ID, IEventCodes.JST_PUB_INC_FAIL,
+ NLS.bind(Messages.IncrementalPublishFail, module.getName()), null);
+ for( int i = 0; i < results.length; i++ )
+ ms.add(results[i]);
+ return ms;
+ }
+
+ IStatus ret = new Status(IStatus.OK, JBossServerCorePlugin.PLUGIN_ID, IEventCodes.JST_PUB_FULL_SUCCESS,
+ NLS.bind(Messages.CountModifiedMembers, PublishUtil.countChanges(delta), module.getName()), null);
+ return ret;
}
+
+
+ protected IStatus createMultiStatus(List<IStatus> list, IModule module) {
+ MultiStatus ms = new MultiStatus(JBossServerCorePlugin.PLUGIN_ID, IEventCodes.JST_PUB_FULL_FAIL,
+ NLS.bind(Messages.FullPublishFail, module.getName()), null);
+ for( int i = 0; i < list.size(); i++ )
+ ms.add(list.get(i));
+ return ms;
+ }
+
+ protected IStatus[] copyBinaryModule(IModule[] moduleTree) {
+ try {
+ IPath remoteDeployPath = getDeployPath(moduleTree, server);
+ IModuleResource[] members = PublishUtil.getResources(moduleTree);
+ File source = PublishUtil.getFile(members[0]);
+ if( source != null ) {
+ SSHZippedJSTPublisher.launchCopyCommand(publishMethod.getSession(), source.toString(), remoteDeployPath.toString());
+ } else {
+// IStatus s = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, IEventCodes.JST_PUB_COPY_BINARY_FAIL,
+// NLS.bind(Messages.CouldNotPublishModule,
+// moduleTree[moduleTree.length-1]), null);
+// return new IStatus[] {s};
+ // TODO
+ }
+ } catch( CoreException ce ) {
+// IStatus s = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, IEventCodes.JST_PUB_COPY_BINARY_FAIL,
+// NLS.bind(Messages.CouldNotPublishModule,
+// moduleTree[moduleTree.length-1]), null);
+// return new IStatus[] {s};
+ // TODO
+ }
+ return new IStatus[]{Status.OK_STATUS};
+ }
+
+ protected IStatus unpublish(IDeployableServer jbServer, IModule[] module,
+ IProgressMonitor monitor) throws CoreException {
+ IPath remotePath = getDeployPath(module, server);
+ SSHZippedJSTPublisher.launchCommand(publishMethod.getSession(), "rm -rf " + remotePath.toString());
+ return Status.OK_STATUS;
+ }
+
+ public static IPath getDeployPath(IModule[] moduleTree, IDeployableServer server) {
+ return PublishUtil.getDeployPath(moduleTree, getRemoteDeployFolder(server.getServer()));
+ }
+
+ protected static String getRemoteDeployFolder(IServer server) {
+ return ((Server)server).getAttribute(ISSHDeploymentConstants.DEPLOY_DIRECTORY, (String)null);
+ }
+
+ public static void mkdirAndCopy(Session session, String localFile, String remoteFile) throws CoreException {
+ String parentFolder = new Path(remoteFile).removeLastSegments(1).toString();
+ SSHZippedJSTPublisher.launchCommand(session, "mkdir -p " + parentFolder);
+ SSHZippedJSTPublisher.launchCopyCommand(session, localFile, remoteFile);
+ }
+
+ public class SSHCopyCallback implements IPublishCopyCallbackHandler {
+
+ private IPath deployRoot;
+ public SSHCopyCallback(IPath deployRoot) {
+ this.deployRoot = deployRoot;
+ }
+
+ public IStatus[] copyFile(IModuleFile mf, IPath path,
+ IProgressMonitor monitor) throws CoreException {
+ File sourceFile = PublishUtil.getFile(mf);
+ IPath destination = deployRoot.append(path);
+ try {
+ mkdirAndCopy(publishMethod.getSession(), sourceFile.getCanonicalPath(), destination.toString());
+ } catch( IOException ioe) {
+ throw new CoreException(new Status(IStatus.ERROR, SSHDeploymentPlugin.PLUGIN_ID, 0,
+ "Error sending file: " + sourceFile.toString(), ioe));
+ }
+ return null;
+ }
+
+ public IStatus[] deleteResource(IPath path, IProgressMonitor monitor) {
+ IPath remotePath = deployRoot.append(path);
+ IStatus ret = Status.OK_STATUS;
+ try {
+ SSHZippedJSTPublisher.launchCommand(publishMethod.getSession(), "rm -rf " + remotePath.toString());
+ } catch( CoreException ce ) {
+ ret = ce.getStatus();
+ }
+ return new IStatus[] { ret };
+ }
+
+ public IStatus[] makeDirectoryIfRequired(IPath dir, IProgressMonitor monitor) {
+ IPath remotePath = deployRoot.append(dir);
+ IStatus ret = Status.OK_STATUS;
+ try {
+ SSHZippedJSTPublisher.launchCommand(publishMethod.getSession(), "mkdir -p " + remotePath.toString());
+ } catch( CoreException ce ) {
+ ret = ce.getStatus();
+ }
+ return new IStatus[] { ret };
+ }
+ }
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHZippedJSTPublisher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHZippedJSTPublisher.java 2009-10-21 17:11:14 UTC (rev 18209)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHZippedJSTPublisher.java 2009-10-21 19:44:06 UTC (rev 18210)
@@ -74,8 +74,7 @@
// Am I a removal? If yes, remove me, and return
if( publishType == IJBossServerPublisher.REMOVE_PUBLISH) {
- launchRemoveCommand(method2.getSession(),
- outputFilepath.toString(), deployFile);
+ launchRemoveCommand(method2.getSession(), deployFile);
} else {
launchCopyCommand(method2.getSession(),
outputFilepath.toString(), deployFile);
@@ -87,14 +86,17 @@
return ((Server)server).getAttribute(ISSHDeploymentConstants.DEPLOY_DIRECTORY, (String)null);
}
- protected void launchRemoveCommand(Session session, String localFile, String remoteLocation) throws CoreException {
+ public static void launchRemoveCommand(Session session, String remoteLocation) throws CoreException {
+ String command = "rm " + remoteLocation;
+ launchCommand(session, command);
+ }
+
+ public static void launchCommand(Session session, String command) throws CoreException {
Channel channel = null;
try {
- String command = "rm " + remoteLocation;
channel = session.openChannel("exec");
((ChannelExec) channel).setCommand(command);
- // get I/O streams for remote scp
channel.connect();
while(!channel.isClosed()) {
try {Thread.sleep(300);} catch(InterruptedException ie) {}
@@ -107,12 +109,12 @@
}
- protected void launchCopyCommand(Session session, String localFile, String remoteLocation) throws CoreException {
+ public static void launchCopyCommand(Session session, String localFile, String remoteFile) throws CoreException {
Channel channel = null;
OutputStream out = null;
try {
// exec 'scp -t rfile' remotely
- String command = "scp -p -t " + remoteLocation;
+ String command = "scp -p -t " + remoteFile;
channel = session.openChannel("exec");
((ChannelExec) channel).setCommand(command);
14 years, 8 months