Author: rob.stryker(a)jboss.com
Date: 2009-10-28 20:14:48 -0400 (Wed, 28 Oct 2009)
New Revision: 18344
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHPackagesPublisher.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/IEventCodes.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/META-INF/MANIFEST.MF
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/SSHDeploymentPlugin.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/ISSHDeploymentConstants.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHPublishUtil.java
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/SSHServerBehaviourDelegate.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHServerDelegate.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHServerRuntime.java
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/SSHZippedJSTPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/ui/editor/DeploymentPage.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/ui/editor/SSHDeploymentModuleTab.java
Log:
Headers and some cleanup / error handling
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/IEventCodes.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/IEventCodes.java 2009-10-28
22:39:10 UTC (rev 18343)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/IEventCodes.java 2009-10-29
00:14:48 UTC (rev 18344)
@@ -40,6 +40,7 @@
// Publishing
public static final int PUBLISHING_ROOT_CODE = PUBLISHING_CODE | (1 << 16);
+ public static final int SSH_PUBLISHING_ROOT_CODE = PUBLISHING_CODE | (1 << 15);
public static final int JST_PUBLISHER_CODE = PUBLISHING_CODE | (2 << 16);
public static final int SINGLE_FILE_PUBLISHER_CODE = PUBLISHING_CODE | (3 << 16);
public static final int ADD_DEPLOYMENT_FOLDER = PUBLISHING_CODE | (4<<16);
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/META-INF/MANIFEST.MF 2009-10-28 22:39:10
UTC (rev 18343)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/META-INF/MANIFEST.MF 2009-10-29 00:14:48
UTC (rev 18344)
@@ -6,21 +6,22 @@
Bundle-Activator: org.jboss.ide.eclipse.as.ssh.SSHDeploymentPlugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- com.jcraft.jsch;bundle-version="0.1.41",
- org.eclipse.jsch.core;bundle-version="1.1.100",
- org.eclipse.jsch.ui;bundle-version="1.1.200",
- org.eclipse.wst.server.core;bundle-version="1.1.102",
- org.eclipse.wst.server.ui;bundle-version="1.1.103",
- org.eclipse.jst.jee;bundle-version="1.0.201",
- org.eclipse.jst.j2ee;bundle-version="1.1.301",
- org.eclipse.jst.j2ee.core;bundle-version="1.1.301",
- org.eclipse.jst.server.core;bundle-version="1.2.0",
- org.jboss.ide.eclipse.as.core;bundle-version="1.0.0",
- org.eclipse.debug.core;bundle-version="3.5.0",
- org.eclipse.wst.common.emfworkbench.integration;bundle-version="1.1.301",
- org.eclipse.jem.util;bundle-version="2.0.200",
- org.jboss.ide.eclipse.archives.webtools;bundle-version="1.0.0",
- org.jboss.ide.eclipse.as.ui;bundle-version="1.0.0",
- org.eclipse.ui.forms;bundle-version="3.4.1"
+ com.jcraft.jsch,
+ org.eclipse.jsch.core,
+ org.eclipse.jsch.ui,
+ org.eclipse.wst.server.core,
+ org.eclipse.wst.server.ui,
+ org.eclipse.jst.jee,
+ org.eclipse.jst.j2ee,
+ org.eclipse.jst.j2ee.core,
+ org.eclipse.jst.server.core,
+ org.jboss.ide.eclipse.as.core,
+ org.eclipse.debug.core,
+ org.eclipse.wst.common.emfworkbench.integration,
+ org.eclipse.jem.util,
+ org.jboss.ide.eclipse.archives.webtools,
+ org.jboss.ide.eclipse.as.ui,
+ org.eclipse.ui.forms,
+ org.jboss.ide.eclipse.archives.core;bundle-version="2.0.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/SSHDeploymentPlugin.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/SSHDeploymentPlugin.java 2009-10-28
22:39:10 UTC (rev 18343)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/SSHDeploymentPlugin.java 2009-10-29
00:14:48 UTC (rev 18344)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.ide.eclipse.as.ssh;
import org.eclipse.ui.plugin.AbstractUIPlugin;
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/ISSHDeploymentConstants.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/ISSHDeploymentConstants.java 2009-10-28
22:39:10 UTC (rev 18343)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/ISSHDeploymentConstants.java 2009-10-29
00:14:48 UTC (rev 18344)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.ide.eclipse.as.ssh.server;
public interface ISSHDeploymentConstants {
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHPackagesPublisher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHPackagesPublisher.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHPackagesPublisher.java 2009-10-29
00:14:48 UTC (rev 18344)
@@ -0,0 +1,147 @@
+package org.jboss.ide.eclipse.as.ssh.server;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+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.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.internal.Server;
+import org.eclipse.wst.server.core.model.IModuleResource;
+import org.eclipse.wst.server.core.model.IModuleResourceDelta;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.webtools.IntegrationPlugin;
+import org.jboss.ide.eclipse.archives.webtools.Messages;
+import org.jboss.ide.eclipse.archives.webtools.modules.PackageModuleFactory;
+import
org.jboss.ide.eclipse.archives.webtools.modules.PackageModuleFactory.PackagedModuleDelegate;
+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.server.xpl.PublishCopyUtil;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.ide.eclipse.as.ssh.server.SSHPublisher.SSHCopyCallback;
+import org.jboss.ide.eclipse.as.ssh.server.SSHServerBehaviourDelegate.SSHPublishMethod;
+
+public class SSHPackagesPublisher implements IJBossServerPublisher {
+
+ protected IDeployableServer server;
+ protected IModuleResourceDelta[] delta;
+ protected ArrayList<IStatus> statuses = new ArrayList<IStatus>();
+ protected SSHPublishMethod method;
+ public SSHPackagesPublisher() {
+ }
+
+ public int getPublishState() {
+ return IServer.PUBLISH_STATE_NONE;
+ }
+
+ public boolean accepts(String method, IServer server, IModule[] module) {
+ if( SSHPublishMethod.SSH_PUBLISH_METHOD.equals(method) && module != null
&& module.length > 0
+ &&
PackageModuleFactory.MODULE_TYPE.equals(module[0].getModuleType().getId()))
+ return true;
+ return false;
+ }
+ public IStatus publishModule(
+ IJBossServerPublishMethod method,
+ IServer server, IModule[] module,
+ int publishType, IModuleResourceDelta[] delta,
+ IProgressMonitor monitor)
+ throws CoreException {
+ this.method = (SSHPublishMethod)method;
+ this.server = ServerConverter.getDeployableServer(server);
+ this.delta = delta;
+ IModule module2 = module[0];
+
+ try {
+ // if it's being removed
+ if( publishType == REMOVE_PUBLISH ) {
+ statuses.addAll(Arrays.asList(removeModule(module2, monitor)));
+ } else if( publishType == FULL_PUBLISH ) {
+ statuses.addAll(Arrays.asList(publishModule(module2, false, monitor)));
+ } else if( publishType == INCREMENTAL_PUBLISH ) {
+ statuses.addAll(Arrays.asList(publishModule(module2, true, monitor)));
+ }
+ }catch(Exception e) {
+ IStatus status = new Status(IStatus.ERROR, IntegrationPlugin.PLUGIN_ID,
+ NLS.bind(Messages.ErrorDuringPublish, module2.getName()), e);
+ return status;
+ }
+
+ if( statuses.size() > 0 ) {
+ MultiStatus ms = new MultiStatus(IntegrationPlugin.PLUGIN_ID, IStatus.ERROR,
+ NLS.bind(Messages.ErrorDuringPublish, module2.getName()), null);
+ for( int i = 0; i < statuses.size(); i++ ) {
+ ms.add(statuses.get(i));
+ }
+ return ms;
+ }
+
+ IStatus ret = new Status(IStatus.OK, IntegrationPlugin.PLUGIN_ID,
+ NLS.bind(Messages.PublishSuccessful, module2.getName()));
+ return ret;
+ }
+
+ protected IStatus[] removeModule(IModule module, IProgressMonitor monitor) {
+ IArchive pack = getPackage(module);
+ // remove all of the deployed items
+ if( pack != null ) {
+ IPath sourcePath = pack.getArchiveFilePath();
+ String deployFolder = getRemoteDeployFolder(server.getServer());
+ String deployFile = new
Path(deployFolder).append(sourcePath.lastSegment()).toString();
+ try {
+ SSHZippedJSTPublisher.launchRemoveCommand(method.getSession(), deployFile, monitor);
+ } catch( CoreException ce ) {
+ return new IStatus[] { ce.getStatus() };
+ }
+ }
+ return new IStatus[] { }; // nothing to report
+ }
+
+
+
+ protected IStatus[] publishModule(IModule module, boolean incremental, IProgressMonitor
monitor) {
+ IArchive pack = getPackage(module);
+ IPath sourcePath = pack.getArchiveFilePath();
+ String remoteContainer = getRemoteDeployFolder(server.getServer());
+ IPath remoteRoot = new Path(remoteContainer).append(sourcePath.lastSegment());
+
+ try {
+ if( incremental ) {
+ IModuleResource[] members = PublishUtil.getResources(module);
+ SSHCopyCallback callback = new SSHCopyCallback(remoteRoot, method);
+ PublishCopyUtil util = new PublishCopyUtil(callback);
+ return util.publishDelta(delta, monitor);
+ } else {
+ if( !pack.isExploded() ) {
+ // copy the output file
+ SSHZippedJSTPublisher.launchCopyCommand(method.getSession(),
sourcePath.toOSString(), remoteRoot.toString(), monitor);
+ } else {
+ IModuleResource[] members = PublishUtil.getResources(module);
+ SSHCopyCallback callback = new SSHCopyCallback(remoteRoot, method);
+ PublishCopyUtil util = new PublishCopyUtil(callback);
+ return util.publishFull(members, monitor);
+ }
+ }
+ } catch( CoreException ce ) {
+ return new IStatus[] { ce.getStatus() };
+ }
+ return new IStatus[] { };
+ }
+
+ protected IArchive getPackage(IModule module) {
+ PackagedModuleDelegate delegate =
(PackagedModuleDelegate)module.loadAdapter(PackagedModuleDelegate.class, new
NullProgressMonitor());
+ return delegate == null ? null : delegate.getPackage();
+ }
+ protected String getRemoteDeployFolder(IServer server) {
+ return ((Server)server).getAttribute(ISSHDeploymentConstants.DEPLOY_DIRECTORY,
(String)null);
+ }
+}
\ No newline at end of file
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHPublishUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHPublishUtil.java 2009-10-28
22:39:10 UTC (rev 18343)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHPublishUtil.java 2009-10-29
00:14:48 UTC (rev 18344)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.ide.eclipse.as.ssh.server;
import org.eclipse.wst.server.core.IServer;
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-28
22:39:10 UTC (rev 18343)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHPublisher.java 2009-10-29
00:14:48 UTC (rev 18344)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.ide.eclipse.as.ssh.server;
import java.io.File;
@@ -106,7 +116,7 @@
ArrayList<IStatus> list = new ArrayList<IStatus>();
if( !PublishUtil.deployPackaged(moduleTree) &&
!PublishUtil.isBinaryObject(moduleTree)) {
- SSHCopyCallback callback = new SSHCopyCallback(remoteDeployPath);
+ SSHCopyCallback callback = new SSHCopyCallback(remoteDeployPath, publishMethod);
PublishCopyUtil util = new PublishCopyUtil(callback);
list.addAll(Arrays.asList(util.publishFull(members, monitor)));
}
@@ -121,7 +131,7 @@
list.addAll(Arrays.asList(PublishUtil.packModuleIntoJar(moduleTree[moduleTree.length-1],
tempFile)));
mkdirAndCopy(publishMethod.getSession(), tempFile.toString(),
remoteDeployPath.toString());
} catch( IOException ioe) {
- // TODO error handling
+ list.add(new Status(IStatus.ERROR, SSHDeploymentPlugin.PLUGIN_ID, ioe.getMessage(),
ioe));
}
}
@@ -134,21 +144,22 @@
IStatus[] results = new IStatus[] {};
IPath remoteDeployPath = getDeployPath(moduleTree, server);
if( !PublishUtil.deployPackaged(moduleTree) &&
!PublishUtil.isBinaryObject(moduleTree)) {
- SSHCopyCallback handler = new SSHCopyCallback(remoteDeployPath);
+ SSHCopyCallback handler = new SSHCopyCallback(remoteDeployPath, publishMethod);
results = new PublishCopyUtil(handler).publishDelta(delta, monitor);
} else if( delta.length > 0 ) {
if( PublishUtil.isBinaryObject(moduleTree))
results = copyBinaryModule(moduleTree, monitor);
else {
IPath localDeployRoot =
JBossServerCorePlugin.getServerStateLocation(server.getServer()).
- append(IJBossServerConstants.DEPLOY).makeAbsolute();
+ 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
+ IStatus s = new Status(IStatus.ERROR, SSHDeploymentPlugin.PLUGIN_ID,
ioe.getMessage(), ioe);
+ results = new IStatus[] { s };
}
}
}
@@ -216,25 +227,27 @@
SSHZippedJSTPublisher.launchCopyCommand(session, localFile, remoteFile, new
NullProgressMonitor());
}
- public class SSHCopyCallback implements IPublishCopyCallbackHandler {
+ public static class SSHCopyCallback implements IPublishCopyCallbackHandler {
- private IPath deployRoot;
- public SSHCopyCallback(IPath deployRoot) {
- this.deployRoot = deployRoot;
+ private IPath root;
+ private SSHPublishMethod method;
+ public SSHCopyCallback(IPath deployRoot, SSHPublishMethod method) {
+ this.root = deployRoot;
+ this.method = method;
}
public IStatus[] copyFile(IModuleFile mf, IPath path,
IProgressMonitor monitor) throws CoreException {
File sourceFile = PublishUtil.getFile(mf);
- IPath destination = deployRoot.append(path);
- mkdirAndCopy(publishMethod.getSession(), sourceFile.getAbsolutePath(),
destination.toString());
+ IPath destination = root.append(path);
+ mkdirAndCopy(method.getSession(), sourceFile.getAbsolutePath(),
destination.toString());
return new IStatus[]{};
}
public IStatus[] deleteResource(IPath path, IProgressMonitor monitor) {
- IPath remotePath = deployRoot.append(path);
+ IPath remotePath = root.append(path);
try {
- SSHZippedJSTPublisher.launchCommand(publishMethod.getSession(), "rm -rf " +
remotePath.toString(), monitor);
+ SSHZippedJSTPublisher.launchCommand(method.getSession(), "rm -rf " +
remotePath.toString(), monitor);
} catch( CoreException ce ) {
return new IStatus[]{ce.getStatus()};
}
@@ -242,9 +255,9 @@
}
public IStatus[] makeDirectoryIfRequired(IPath dir, IProgressMonitor monitor) {
- IPath remotePath = deployRoot.append(dir);
+ IPath remotePath = root.append(dir);
try {
- SSHZippedJSTPublisher.launchCommand(publishMethod.getSession(), "mkdir -p "
+ remotePath.toString(), monitor);
+ SSHZippedJSTPublisher.launchCommand(method.getSession(), "mkdir -p " +
remotePath.toString(), monitor);
} catch( CoreException ce ) {
return new IStatus[]{ce.getStatus()};
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHServerBehaviourDelegate.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHServerBehaviourDelegate.java 2009-10-28
22:39:10 UTC (rev 18343)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHServerBehaviourDelegate.java 2009-10-29
00:14:48 UTC (rev 18344)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.ide.eclipse.as.ssh.server;
import org.eclipse.core.runtime.CoreException;
@@ -2,6 +12,10 @@
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerCore;
import org.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethod;
import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
+import org.jboss.ide.eclipse.as.ssh.SSHDeploymentPlugin;
@@ -52,7 +66,7 @@
session.setUserInfo(info);
session.connect();
} catch( JSchException jsche) {
- // TODO handle
+ throw new CoreException(new Status(IStatus.ERROR, SSHDeploymentPlugin.PLUGIN_ID,
"Remote Authentication Error", jsche));
}
}
@@ -73,6 +87,8 @@
private String password;
private String hostsFile;
public ServerUserInfo(IServer server) {
+ IServer tmp = ServerCore.findServer(server.getId());
+ String tmp_pass = SSHPublishUtil.getPass(tmp);
user = SSHPublishUtil.getUser(server);
password = SSHPublishUtil.getPass(server);
hostsFile = SSHPublishUtil.getHostsFile(server);
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHServerDelegate.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHServerDelegate.java 2009-10-28
22:39:10 UTC (rev 18343)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHServerDelegate.java 2009-10-29
00:14:48 UTC (rev 18344)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.ide.eclipse.as.ssh.server;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHServerRuntime.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHServerRuntime.java 2009-10-28
22:39:10 UTC (rev 18343)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHServerRuntime.java 2009-10-29
00:14:48 UTC (rev 18344)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.ide.eclipse.as.ssh.server;
import org.eclipse.wst.server.core.model.RuntimeDelegate;
Modified:
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 2009-10-28
22:39:10 UTC (rev 18343)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHSingleFilePublisher.java 2009-10-29
00:14:48 UTC (rev 18344)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.ide.eclipse.as.ssh.server;
import org.eclipse.core.runtime.CoreException;
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-28
22:39:10 UTC (rev 18343)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHZippedJSTPublisher.java 2009-10-29
00:14:48 UTC (rev 18344)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.ide.eclipse.as.ssh.server;
import java.io.File;
@@ -19,6 +29,9 @@
import org.eclipse.wst.server.core.model.IModuleResourceDelta;
import org.jboss.ide.eclipse.archives.webtools.modules.LocalZippedPublisherUtil;
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.extensions.events.ServerLogger;
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;
@@ -92,6 +105,18 @@
}
public static void launchCommand(Session session, String command, IProgressMonitor
monitor) throws CoreException {
+ launchThreadedCommand(session, command, monitor);
+ }
+
+ protected static void launchThreadedCommand(final Session session, final String command,
final IProgressMonitor monitor) throws CoreException {
+ // thread and watch the monitor for cancelations and interrupt the thread
+ LaunchRunnable r = new LaunchRunnable() { public void run() throws CoreException {
+ launchCommandNoThread(session, command, monitor);
+ } };
+ launchThreadedCommand(r, monitor);
+ }
+
+ protected static void launchCommandNoThread(Session session, String command,
IProgressMonitor monitor) throws CoreException {
Channel channel = null;
try {
channel = session.openChannel("exec");
@@ -102,17 +127,73 @@
try {Thread.sleep(300);} catch(InterruptedException ie) {}
}
} catch( JSchException jsche ) {
- throw new CoreException(new Status(IStatus.ERROR, SSHDeploymentPlugin.PLUGIN_ID,
"Error Removing Remote File"));
+ throw new CoreException(new Status(IStatus.ERROR, SSHDeploymentPlugin.PLUGIN_ID,
IEventCodes.SSH_PUBLISHING_ROOT_CODE, "Error executing command: " + command,
null));
} finally {
channel.disconnect();
}
-
}
- public static void launchCopyCommand(Session session, String localFile, String
remoteFile, IProgressMonitor monitor) throws CoreException {
- launchCopyCommandImpl(session, localFile, remoteFile, monitor);
+ public static class LaunchRunnable {
+ public void run() throws CoreException {
+ }
}
+ public static void launchCopyCommand(final Session session, final String localFile,
+ final String remoteFile, final IProgressMonitor monitor) throws CoreException {
+ // thread and watch the monitor for cancelations and interrupt the thread
+ LaunchRunnable r = new LaunchRunnable() { public void run() throws CoreException {
+ launchCopyCommandImpl(session, localFile, remoteFile, monitor);
+ } };
+ launchThreadedCommand(r, monitor);
+ }
+
+ protected static void launchThreadedCommand(final LaunchRunnable runnable,
IProgressMonitor monitor) throws CoreException {
+ final Exception[] e = new Exception[1];
+ e[0] = null;
+ final Object waitObject = new Object();
+ final Boolean[] subtaskComplete = new Boolean[1];
+ subtaskComplete[0] = new Boolean(false);
+ Thread t = new Thread() {
+ public void run() {
+ Exception exception = null;
+ try {
+ runnable.run();
+ } catch( Exception ex ) {
+ exception = ex;
+ }
+ synchronized(waitObject) {
+ e[0] = exception;
+ subtaskComplete[0] = new Boolean(true);
+ waitObject.notifyAll();
+ }
+ }
+ };
+ t.start();
+ while(t.isAlive() && !monitor.isCanceled() ) {
+ synchronized(waitObject) {
+ if( subtaskComplete[0].booleanValue() )
+ break;
+ try {
+ waitObject.wait(500);
+ } catch(InterruptedException ie) {}
+ }
+ }
+ synchronized(waitObject) {
+ if( !subtaskComplete[0].booleanValue()) {
+ t.interrupt();
+ IStatus status = new Status(IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID,
IEventCodes.ISTATUS_CODE_ERROR, "SSH command canceled", e[0]);
+ CoreException ce = new CoreException(status);
+ throw ce;
+ }
+ if( e[0] != null ) {
+ IStatus status = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
IEventCodes.ISTATUS_CODE_ERROR, "Error running remote command", e[0]);
+ CoreException ce = new CoreException(status);
+ throw ce;
+ }
+
+ }
+ }
+
protected static void launchCopyCommandImpl(Session session, String localFile, String
remoteFile, IProgressMonitor monitor) throws CoreException {
Channel channel = null;
OutputStream out = null;
@@ -127,7 +208,7 @@
InputStream in = channel.getInputStream();
channel.connect();
if (checkAck(in) != 0) {
- throw new CoreException(new Status(IStatus.ERROR, SSHDeploymentPlugin.PLUGIN_ID,
"no idea bug"));
+ throw new CoreException(new Status(IStatus.ERROR, SSHDeploymentPlugin.PLUGIN_ID,
IEventCodes.SSH_PUBLISHING_ROOT_CODE, "Error transfering file: " + localFile,
null));
}
// send "C0644 filesize filename", where filename should not include
@@ -143,8 +224,7 @@
out.write(command.getBytes());
out.flush();
if (checkAck(in) != 0) {
- // TODO throw new exception
- throw new CoreException(new Status(IStatus.ERROR, SSHDeploymentPlugin.PLUGIN_ID,
"Error transfering file"));
+ throw new CoreException(new Status(IStatus.ERROR, SSHDeploymentPlugin.PLUGIN_ID,
IEventCodes.SSH_PUBLISHING_ROOT_CODE, "Error transfering file: " + localFile,
null));
}
// send a content of lfile
@@ -163,13 +243,13 @@
out.write(buf, 0, 1);
out.flush();
if (checkAck(in) != 0) {
- System.exit(0);
+ throw new CoreException(new Status(IStatus.ERROR, SSHDeploymentPlugin.PLUGIN_ID,
IEventCodes.SSH_PUBLISHING_ROOT_CODE, "Error transfering file: " + localFile,
null));
}
} catch( JSchException jsche ) {
- throw new CoreException(new Status(IStatus.ERROR, SSHDeploymentPlugin.PLUGIN_ID,
"Error transfering file"));
+ throw new CoreException(new Status(IStatus.ERROR, SSHDeploymentPlugin.PLUGIN_ID,
IEventCodes.SSH_PUBLISHING_ROOT_CODE, "Error transfering file: " + localFile,
jsche));
} catch( IOException ioe) {
- throw new CoreException(new Status(IStatus.ERROR, SSHDeploymentPlugin.PLUGIN_ID,
"Error transfering file"));
+ throw new CoreException(new Status(IStatus.ERROR, SSHDeploymentPlugin.PLUGIN_ID,
IEventCodes.SSH_PUBLISHING_ROOT_CODE, "Error transfering file: " + localFile,
ioe));
} finally {
if( channel != null )
channel.disconnect();
@@ -199,12 +279,12 @@
c = in.read();
sb.append((char) c);
} while (c != '\n');
- if (b == 1) { // error
- System.out.print(sb.toString());
- }
- if (b == 2) { // fatal error
- System.out.print(sb.toString());
- }
+// if (b == 1) { // error
+// System.out.print(sb.toString());
+// }
+// if (b == 2) { // fatal error
+// System.out.print(sb.toString());
+// }
}
return b;
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/ui/editor/DeploymentPage.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/ui/editor/DeploymentPage.java 2009-10-28
22:39:10 UTC (rev 18343)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/ui/editor/DeploymentPage.java 2009-10-29
00:14:48 UTC (rev 18344)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.ide.eclipse.as.ssh.ui.editor;
import org.eclipse.swt.SWT;
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/ui/editor/SSHDeploymentModuleTab.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/ui/editor/SSHDeploymentModuleTab.java 2009-10-28
22:39:10 UTC (rev 18343)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/ui/editor/SSHDeploymentModuleTab.java 2009-10-29
00:14:48 UTC (rev 18344)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.ide.eclipse.as.ssh.ui.editor;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -11,11 +21,9 @@
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
@@ -39,13 +47,12 @@
public class SSHDeploymentModuleTab implements IDeploymentEditorTab {
private ModuleDeploymentPage page;
- private DeploymentPreferences preferences;
public SSHDeploymentModuleTab() {
}
public String getTabName() {
- return "SSH Deployment";
+ return Messages.SSHDeploymentSectionTitle;
}
public void setDeploymentPage(ModuleDeploymentPage page) {
@@ -53,7 +60,7 @@
}
public void setDeploymentPrefs(DeploymentPreferences prefs) {
- this.preferences = prefs;
+ // DO Nothing
}
public Control createControl(Composite parent) {