[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[stp-dev] Add function for SOAS to support undeploy package from server, bugId:162516
|
Title: Add function for SOAS to support undeploy package from server, bugId:162516
Hi all
I create a patch for https://bugs.eclipse.org/bugs/show_bug.cgi?id=162516 ,
to make SOAS support undeploy action to remove service componemnts from server.
To implement this function :
1). Add a button "Undeploy Packages" on Configuration page in DeployEditor,
2). Add two method to the interface "org.eclipse.stp.soas.deploy.core.IDeploySession" ,
void undeploy(IPackageOutputDescriptor descriptor) throws Exception
IStatus[] preUndeployCheck(IPackageOutputDescriptor descriptor);
Can anybody take a look please?
Thanks
Denny
<<patch_for_undeploy.txt>>
### Eclipse Workspace Patch 1.0
#P org.eclipse.stp.soas.example.deploydriver
Index: src/org/eclipse/stp/soas/example/FileDeploySession.java
===================================================================
RCS file: /cvsroot/stp/org.eclipse.stp.soas/org.eclipse.stp.soas.example.deploydriver/src/org/eclipse/stp/soas/example/FileDeploySession.java,v
retrieving revision 1.1
diff -u -r1.1 FileDeploySession.java
--- src/org/eclipse/stp/soas/example/FileDeploySession.java 21 Jun 2006 03:12:33 -0000 1.1
+++ src/org/eclipse/stp/soas/example/FileDeploySession.java 17 Apr 2007 06:17:47 -0000
@@ -138,4 +138,17 @@
}
}
+ @Override
+ public void undeploy(IPackageOutputDescriptor descriptor) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public IStatus[] preUndeployCheck(IPackageOutputDescriptor descriptor) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
}
\ No newline at end of file
#P org.eclipse.stp.soas.deploy.core
Index: src/org/eclipse/stp/soas/deploy/core/ui/actions/DeployPackageActionDelegate.java
===================================================================
RCS file: /cvsroot/stp/org.eclipse.stp.soas/org.eclipse.stp.soas.deploy.core/src/org/eclipse/stp/soas/deploy/core/ui/actions/DeployPackageActionDelegate.java,v
retrieving revision 1.1
diff -u -r1.1 DeployPackageActionDelegate.java
--- src/org/eclipse/stp/soas/deploy/core/ui/actions/DeployPackageActionDelegate.java 21 Jun 2006 03:03:22 -0000 1.1
+++ src/org/eclipse/stp/soas/deploy/core/ui/actions/DeployPackageActionDelegate.java 17 Apr 2007 06:18:38 -0000
@@ -10,121 +10,13 @@
******************************************************************************/
package org.eclipse.stp.soas.deploy.core.ui.actions;
-import java.util.Random;
+import org.eclipse.swt.widgets.Shell;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.stp.soas.deploy.core.IPackage;
-import org.eclipse.stp.soas.deploy.core.DeployCorePlugin;
-import org.eclipse.stp.soas.deploy.models.deployfile.DeployConfiguration;
-import org.eclipse.stp.soas.deploy.models.deployfile.DeployFileFactory;
-import org.eclipse.stp.soas.deploy.models.deployfile.DeployPackage;
-import org.eclipse.stp.soas.deploy.models.deployfile.DeployServer;
-import org.eclipse.stp.soas.deploy.models.deployfile.Root;
-import org.eclipse.stp.soas.internal.deploy.ui.dialogs.Dialog;
-import org.eclipse.stp.soas.internal.deploy.ui.dialogs.ServerSelectionDialogPage;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.ui.IActionDelegate;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
+public class DeployPackageActionDelegate extends BasePackageActionDelegate {
+
-public class DeployPackageActionDelegate implements IObjectActionDelegate {
-
- private IStructuredSelection mSelection = null;
-
- /**
- * Constructor for CreatePackageFileAction.
- */
- public DeployPackageActionDelegate() {
- super();
- }
-
- /**
- * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
- */
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction,
- * org.eclipse.swt.widgets.Event)
- */
- public void runWithEvent(IAction action, Event event) {
- run(action);
- }
-
- /**
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- */
- public void run(Event event) {
- run((IAction) null);
- }
-
- /**
- * @see IActionDelegate#run(IAction)
- */
- public void run(IAction action) {
- if (mSelection == null
- || !(mSelection.getFirstElement() instanceof IPackage)) {
- return;
- }
- IPackage thePackage = (IPackage) mSelection.getFirstElement();
- Root root = DeployFileFactory.eINSTANCE.createRoot();
- DeployPackage deployPackage = DeployFileFactory.eINSTANCE
- .createDeployPackage(root, thePackage.getFile()
- .getProjectRelativePath().toString());
- DeployConfiguration deployConfig = DeployFileFactory.eINSTANCE
- .createDeployConfiguration(null, deployPackage);
-
- ServerSelectionDialogPage page = new ServerSelectionDialogPage();
- Dialog dialog = new Dialog(DeployCorePlugin.getDefault()
- .getWorkbench().getActiveWorkbenchWindow().getShell(), page);
-
- page.init(deployPackage, thePackage, null);
- if (dialog.open() == Dialog.OK) {
- ResourceSet rs = new ResourceSetImpl();
- Resource resource = rs
- .createResource(createDeployResourceURI(thePackage));
- DeployServer target = page.getSelectedDeployServer();
-
- resource.getContents().add(root);
-
- root.getServer().add(target);
- deployConfig.setTargetServer(target);
-
- ExecuteDeployAction deployAction = new ExecuteDeployAction(
- new String(), DeployCorePlugin.getDefault()
- .getWorkbench().getActiveWorkbenchWindow()
- .getShell());
- deployAction.selectionChanged(new StructuredSelection(root));
- deployAction.run();
- }
- }
-
- /**
- * @see IActionDelegate#selectionChanged(IAction, ISelection)
- */
- public void selectionChanged(IAction action, ISelection selection) {
- if (selection instanceof IStructuredSelection) {
- mSelection = (IStructuredSelection) selection;
- }
- }
-
- private URI createDeployResourceURI(IPackage thePackage) {
- IPath pkgPath = thePackage.getFile().getFullPath();
- String pkgName = pkgPath.removeFileExtension().lastSegment();
- String deployName = pkgName + '_' + Math.abs(new Random().nextInt());
- IPath deployPath = pkgPath.removeLastSegments(1).append(deployName)
- .addFileExtension("deploy"); //$NON-NLS-1$
- return URI.createPlatformResourceURI(deployPath.toString());
+ @Override
+ protected BaseAction getExecuteAction(Shell shell) {
+ return new ExecuteDeployAction(new String(""), shell);
}
}
\ No newline at end of file
Index: src/org/eclipse/stp/soas/deploy/core/ui/actions/ExecuteDeployAction.java
===================================================================
RCS file: /cvsroot/stp/org.eclipse.stp.soas/org.eclipse.stp.soas.deploy.core/src/org/eclipse/stp/soas/deploy/core/ui/actions/ExecuteDeployAction.java,v
retrieving revision 1.1
diff -u -r1.1 ExecuteDeployAction.java
--- src/org/eclipse/stp/soas/deploy/core/ui/actions/ExecuteDeployAction.java 21 Jun 2006 03:03:22 -0000 1.1
+++ src/org/eclipse/stp/soas/deploy/core/ui/actions/ExecuteDeployAction.java 17 Apr 2007 06:18:38 -0000
@@ -10,19 +10,16 @@
******************************************************************************/
package org.eclipse.stp.soas.deploy.core.ui.actions;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.stp.soas.deploy.core.DeployCorePlugin;
import org.eclipse.stp.soas.deploy.core.operations.ExecuteDeploymentJob;
-import org.eclipse.stp.soas.deploy.models.deployfile.Root;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.actions.BaseSelectionListenerAction;
/**
* @author rcernich
*
* Created on Jan 21, 2005
*/
-public class ExecuteDeployAction extends BaseSelectionListenerAction {
+public class ExecuteDeployAction extends BaseAction {
private Shell mShell;
@@ -37,20 +34,6 @@
/*
* (non-Javadoc)
*
- * @see org.eclipse.ui.actions.BaseSelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
- */
- protected boolean updateSelection(IStructuredSelection selection) {
- boolean retVal = super.updateSelection(selection);
- if (retVal) {
- setEnabled(selection.size() == 1
- && selection.getFirstElement() instanceof Root);
- }
- return retVal && true;
- }
-
- /*
- * (non-Javadoc)
- *
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
@@ -66,7 +49,5 @@
deployOp.schedule();
}
- private Root getSelectedRoot() {
- return (Root) getStructuredSelection().getFirstElement();
- }
+
}
\ No newline at end of file
Index: src/org/eclipse/stp/soas/deploy/core/PluginResources.properties
===================================================================
RCS file: /cvsroot/stp/org.eclipse.stp.soas/org.eclipse.stp.soas.deploy.core/src/org/eclipse/stp/soas/deploy/core/PluginResources.properties,v
retrieving revision 1.1
diff -u -r1.1 PluginResources.properties
--- src/org/eclipse/stp/soas/deploy/core/PluginResources.properties 21 Jun 2006 03:03:23 -0000 1.1
+++ src/org/eclipse/stp/soas/deploy/core/PluginResources.properties 17 Apr 2007 06:18:31 -0000
@@ -50,11 +50,17 @@
Deploy.ERROR.PackageDoesNotExist=The package, {0} for deployment to server, {1} does not exist.
Deploy.ERROR.Generic=An error occurred deploying package, {0} to server, {1} (Exception: {2}).
+Undeploy.ERROR.Generic=An error occurred undeploying package, {0} from server, {1} (Exception: {2}).
Deploy.SUCCESS.Generic=Successfully deployed package, {0} to server, {1}.
+Undeploy.SUCCESS.Generic=Successfully undeployed package, {0} from server, {1}.
DeployStatusDialog.TITLE=Deployment Status
DeployStatusDialog.MESSAGE.Success=Success!
DeployStatusDialog.MESSAGE.Error=Errors occurred. The table below lists the status of the deployment operation.
+UndeployStatusDialog.TITLE=Undeployment Status
+UndeployStatusDialog.MESSAGE.Success=Success!
+UndeployStatusDialog.MESSAGE.Error=Errors occurred. The table below lists the status of the undeployment operation.
+
ConfigurationDialog.TITLE=Configuration for {0} on {1}
ConfigurationPage.success.title=Success
ConfigurationPage.success.message=Packages created.
@@ -261,13 +267,16 @@
SupportedTechnologyType.trace.error.invalidTypeSpecified=Deployment Extension Error: invalid type specified in supportedTechnology element
ServerType.toString=ServerType (serverDefinition={0}, version={1})
ExecuteDeploymentJob.task.name=Executing Deployment...
+ExecuteUndeploymentJob.task.name=Executing Undeployment...
ExecuteDeploymentJob.subtask.preDeployCheck=Pre-deploy check for {0} to {1}
ExecuteDeploymentJob.error.deployError=Error deploying package {0} to {1}: Package does not exist.
ExecuteDeploymentJob.subtask.deploy=Deploying {0} to {1}
ExecuteDeploymentJob.subtask.refresh=Refreshing {0} in Enterprise Browser
ExecuteDeploymentJob.error.log.message=Deploying Package Failed
ExecuteDeploymentJob.error.job=Errors occurred during deployment execution.
+ExecuteUndeploymentJob.error.job=Errors occurred during undeployment execution.
ExecuteDeploymentJob.action.name=Show Deployment Status
+ExecuteUndeploymentJob.action.name=Show Undeployment Status
TargetMapTableViewer.column.heading.package=Package
TargetMapTableViewer.column.heading.target=Target
ConnectionProfileSelectionDialogPage.error.selectConnectionProfile=Please select a connection profile.
@@ -275,6 +284,7 @@
ConnectionProfileSelectionDialogPage.LABLE.selectConnectionProfile=Select connection profile:
ConfigurationPage.BUTTON.createPackages=Create packages
ConfigurationPage.BUTTON.deployPackages=Deploy packages
+ConfigurationPage.BUTTON.undeployPackages=Undeploy packages
ConfigurationPage.action.deployPackages=Deploy Packages
ConfigurationPage.title.containerSelection=Select an output directory for the packages.
Index: src/org/eclipse/stp/soas/deploy/core/DeploySessionBase.java
===================================================================
RCS file: /cvsroot/stp/org.eclipse.stp.soas/org.eclipse.stp.soas.deploy.core/src/org/eclipse/stp/soas/deploy/core/DeploySessionBase.java,v
retrieving revision 1.1
diff -u -r1.1 DeploySessionBase.java
--- src/org/eclipse/stp/soas/deploy/core/DeploySessionBase.java 21 Jun 2006 03:03:23 -0000 1.1
+++ src/org/eclipse/stp/soas/deploy/core/DeploySessionBase.java 17 Apr 2007 06:18:06 -0000
@@ -69,5 +69,15 @@
*/
public abstract void deploy(IPackageOutputDescriptor descriptor)
throws Exception;
-
+
+ /* (non-Javadoc)
+ * @see org.eclipse.stp.soas.deploy.core.IDeploySession#deploy(org.eclipse.stp.soas.deploy.core.IPackageOutputDescriptor)
+ */
+ public abstract void undeploy(IPackageOutputDescriptor descriptor)
+ throws Exception;
+
+ public abstract IStatus[] preUndeployCheck(IPackageOutputDescriptor descriptor);
+
+
+
}
\ No newline at end of file
Index: src/org/eclipse/stp/soas/deploy/core/IDeploySession.java
===================================================================
RCS file: /cvsroot/stp/org.eclipse.stp.soas/org.eclipse.stp.soas.deploy.core/src/org/eclipse/stp/soas/deploy/core/IDeploySession.java,v
retrieving revision 1.1
diff -u -r1.1 IDeploySession.java
--- src/org/eclipse/stp/soas/deploy/core/IDeploySession.java 21 Jun 2006 03:03:23 -0000 1.1
+++ src/org/eclipse/stp/soas/deploy/core/IDeploySession.java 17 Apr 2007 06:18:10 -0000
@@ -42,6 +42,13 @@
*/
IStatus[] preDeployCheck(IPackageOutputDescriptor descriptor);
+
+
+ /**
+ * @param descriptor
+ * @return
+ */
+ IStatus[] preUndeployCheck(IPackageOutputDescriptor descriptor);
/**
* Deploys the package defined by the descriptor to the server.
*
@@ -51,6 +58,13 @@
*/
void deploy(IPackageOutputDescriptor descriptor) throws Exception;
+
+ /**
+ * Undeploy the package from the server
+ * @param descriptor the package being deployed
+ * @throws Exception
+ */
+ void undeploy(IPackageOutputDescriptor descriptor) throws Exception;
/**
* Disposes of this deploy session. At this time, the session should
* release any resources it may have allocated during deployment operations.
Index: src/org/eclipse/stp/soas/internal/deploy/ui/editors/ConfigurationPage.java
===================================================================
RCS file: /cvsroot/stp/org.eclipse.stp.soas/org.eclipse.stp.soas.deploy.core/src/org/eclipse/stp/soas/internal/deploy/ui/editors/ConfigurationPage.java,v
retrieving revision 1.1
diff -u -r1.1 ConfigurationPage.java
--- src/org/eclipse/stp/soas/internal/deploy/ui/editors/ConfigurationPage.java 21 Jun 2006 03:03:26 -0000 1.1
+++ src/org/eclipse/stp/soas/internal/deploy/ui/editors/ConfigurationPage.java 17 Apr 2007 06:18:46 -0000
@@ -18,7 +18,9 @@
import org.eclipse.stp.soas.deploy.core.IHelpConstants;
import org.eclipse.stp.soas.deploy.core.DeployCorePlugin;
import org.eclipse.stp.soas.deploy.core.operations.CreateDeployPackagesJob;
+import org.eclipse.stp.soas.deploy.core.operations.ExecuteUndeploymentJob;
import org.eclipse.stp.soas.deploy.core.ui.actions.ExecuteDeployAction;
+import org.eclipse.stp.soas.deploy.core.ui.actions.ExecuteUndeployAction;
import org.eclipse.stp.soas.deploy.models.deployfile.Root;
import org.eclipse.stp.soas.internal.deploy.emf.editors.EMFFormEditor;
import org.eclipse.stp.soas.internal.deploy.emf.editors.EMFFormPage;
@@ -53,7 +55,9 @@
private ServersSection mServers;
private Button mCreatePackagesButton;
private Button mDeployButton;
+ private Button mUndeployButton;
private ExecuteDeployAction mDeployAction;
+ private ExecuteUndeployAction mUndeployAction;
/**
* @param editor
@@ -117,7 +121,7 @@
FormToolkit toolkit = managedForm.getToolkit();
Composite buttons = toolkit.createComposite(form.getBody());
- buttons.setLayout(new GridLayout(2, false));
+ buttons.setLayout(new GridLayout(3, false));
GridData gd = new GridData();
gd.horizontalSpan = 2;
buttons.setLayoutData(gd);
@@ -146,20 +150,46 @@
handleDeploy();
}
});
+
+
mDeployAction = new ExecuteDeployAction(DeployCorePlugin
.getDefault().getResourceString(
"ConfigurationPage.action.deployPackages"), form //$NON-NLS-1$
.getShell());
mDeployAction.selectionChanged(new StructuredSelection(
getEMFFormEditor().getModelRoot()));
+
+
+ mUndeployButton = toolkit.createButton(buttons, DeployCorePlugin
+ .getDefault().getResourceString(
+ "ConfigurationPage.BUTTON.undeployPackages"), //$NON-NLS-1$
+ SWT.PUSH);
+ mUndeployButton.setLayoutData(new GridData(
+ GridData.HORIZONTAL_ALIGN_BEGINNING));
+ mUndeployButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ handleUndeploy();
+ }
+ });
+
+ mUndeployAction = new ExecuteUndeployAction(DeployCorePlugin
+ .getDefault().getResourceString(
+ "ConfigurationPage.action.deployPackages"), form //$NON-NLS-1$
+ .getShell());
+ mUndeployAction.selectionChanged(new StructuredSelection(
+ getEMFFormEditor().getModelRoot()));
}
private void handleDeploy() {
mDeployAction.run();
}
- private void handleCreatePackages() {
- // Make sure any dirty files are saved.
+ private void handleUndeploy() {
+ mUndeployAction.run();
+ }
+
+ private void handleCreatePackages() {
if (!DeployCorePlugin.getDefault().getWorkbench()
.saveAllEditors(true)) {
return;
@@ -176,7 +206,6 @@
createPackages.schedule();
}
-
private void handleFinish(CreateDeployPackagesJob createPackages,
IStatus status) {
if (status.getSeverity() == IStatus.ERROR) {
Index: plugin.xml
===================================================================
RCS file: /cvsroot/stp/org.eclipse.stp.soas/org.eclipse.stp.soas.deploy.core/plugin.xml,v
retrieving revision 1.2
diff -u -r1.2 plugin.xml
--- plugin.xml 30 Jan 2007 07:46:13 -0000 1.2
+++ plugin.xml 17 Apr 2007 06:18:06 -0000
@@ -54,6 +54,16 @@
</enablement>
</action>
<action
+ class="org.eclipse.stp.soas.deploy.core.ui.actions.UndeployPackageActionDelegate"
+ enablesFor="+"
+ id="org.eclipse.stp.soas.deploy.core.ui.actions.executeUndeployAction"
+ label="%undeployPackage"
+ menubarPath="additions">
+ <enablement>
+ <objectClass name="org.eclipse.stp.soas.deploy.core.IPackage"/>
+ </enablement>
+ </action>
+ <action
label="%createPackage"
class="org.eclipse.stp.soas.deploy.core.ui.actions.CreatePackageFileActionDelegate"
menubarPath="additions"
Index: plugin.properties
===================================================================
RCS file: /cvsroot/stp/org.eclipse.stp.soas/org.eclipse.stp.soas.deploy.core/plugin.properties,v
retrieving revision 1.2
diff -u -r1.2 plugin.properties
--- plugin.properties 28 Nov 2006 09:04:21 -0000 1.2
+++ plugin.properties 17 Apr 2007 06:18:04 -0000
@@ -28,6 +28,7 @@
executeDeployment = Execute Deployment
deployPackage=Deploy...
+undeployPackage=Undeploy...
createPackage=Build Package...
deploymentDefinitionProblemMarkerName=Deployment Profile Problem Marker
Index: src/org/eclipse/stp/soas/internal/deploy/core/DeployTarget.java
===================================================================
RCS file: /cvsroot/stp/org.eclipse.stp.soas/org.eclipse.stp.soas.deploy.core/src/org/eclipse/stp/soas/internal/deploy/core/DeployTarget.java,v
retrieving revision 1.1
diff -u -r1.1 DeployTarget.java
--- src/org/eclipse/stp/soas/internal/deploy/core/DeployTarget.java 21 Jun 2006 03:03:25 -0000 1.1
+++ src/org/eclipse/stp/soas/internal/deploy/core/DeployTarget.java 17 Apr 2007 06:18:39 -0000
@@ -37,7 +37,7 @@
* @see org.eclipse.stp.soas.deploy.core.IDeployTarget#createDeploySession()
*/
public IDeploySession createDeploySession() {
- return mDeployDriver.createDeploySession(mProfile);
+ return mDeployDriver.createDeploySession(mProfile);
}
/* (non-Javadoc)
Index: src/org/eclipse/stp/soas/deploy/core/operations/CreateDeployPackagesJob.java
===================================================================
RCS file: /cvsroot/stp/org.eclipse.stp.soas/org.eclipse.stp.soas.deploy.core/src/org/eclipse/stp/soas/deploy/core/operations/CreateDeployPackagesJob.java,v
retrieving revision 1.1
diff -u -r1.1 CreateDeployPackagesJob.java
--- src/org/eclipse/stp/soas/deploy/core/operations/CreateDeployPackagesJob.java 21 Jun 2006 03:03:24 -0000 1.1
+++ src/org/eclipse/stp/soas/deploy/core/operations/CreateDeployPackagesJob.java 17 Apr 2007 06:18:38 -0000
@@ -267,7 +267,7 @@
IPackage ip = Utilities.adaptToIPackage(deployPackage);
if (ip instanceof ILogicalPackage) {
- ILogicalPackage ilp = (ILogicalPackage) ip;
+ ILogicalPackage ilp = (ILogicalPackage) ip;
for (Iterator trgIt = deployPackage
.getTargetConfiguration().iterator(); trgIt
.hasNext();) {
Index: src/org/eclipse/stp/soas/deploy/core/ui/actions/ExecuteUndeployAction.java
===================================================================
RCS file: src/org/eclipse/stp/soas/deploy/core/ui/actions/ExecuteUndeployAction.java
diff -N src/org/eclipse/stp/soas/deploy/core/ui/actions/ExecuteUndeployAction.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/stp/soas/deploy/core/ui/actions/ExecuteUndeployAction.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,35 @@
+package org.eclipse.stp.soas.deploy.core.ui.actions;
+
+import org.eclipse.stp.soas.deploy.core.DeployCorePlugin;
+import org.eclipse.stp.soas.deploy.core.operations.ExecuteUndeploymentJob;
+import org.eclipse.swt.widgets.Shell;
+
+public class ExecuteUndeployAction extends BaseAction {
+
+
+ private Shell mShell;
+
+ /**
+ * @param text
+ */
+ public ExecuteUndeployAction(String text, Shell shell) {
+ super(text);
+ mShell = shell;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.action.IAction#run()
+ */
+ public void run() {
+
+ ExecuteUndeploymentJob deployOp = new ExecuteUndeploymentJob(
+ getSelectedRoot(), mShell);
+
+ deployOp.schedule();
+ }
+
+
+
+}
Index: src/org/eclipse/stp/soas/deploy/core/operations/ExecuteUndeploymentJob.java
===================================================================
RCS file: src/org/eclipse/stp/soas/deploy/core/operations/ExecuteUndeploymentJob.java
diff -N src/org/eclipse/stp/soas/deploy/core/operations/ExecuteUndeploymentJob.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/stp/soas/deploy/core/operations/ExecuteUndeploymentJob.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,517 @@
+/*******************************************************************************
+ * Copyright (c) 2004-2006 Sybase, Inc.
+ *
+ * All rights reserved. This program and the accompanying materials are 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: Sybase, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.stp.soas.deploy.core.operations;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.datatools.connectivity.IConnectionProfile;
+import org.eclipse.datatools.connectivity.ProfileManager;
+import org.eclipse.datatools.connectivity.ui.RefreshProfileJob;
+import org.eclipse.datatools.connectivity.ui.dse.DSEPlugin;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.stp.soas.deploy.core.DeployCorePlugin;
+import org.eclipse.stp.soas.deploy.core.IDeploySession;
+import org.eclipse.stp.soas.deploy.core.IDeployTarget;
+import org.eclipse.stp.soas.deploy.core.IPackageOutputDescriptor;
+import org.eclipse.stp.soas.deploy.core.Utilities;
+import org.eclipse.stp.soas.deploy.models.deployfile.DeployConfiguration;
+import org.eclipse.stp.soas.deploy.models.deployfile.DeployPackage;
+import org.eclipse.stp.soas.deploy.models.deployfile.DeployServer;
+import org.eclipse.stp.soas.deploy.models.deployfile.Root;
+import org.eclipse.stp.soas.internal.deploy.ui.dialogs.DeployStatusDialogPage;
+import org.eclipse.stp.soas.internal.deploy.ui.dialogs.Dialog;
+import org.eclipse.stp.soas.internal.deploy.ui.dialogs.PreDeployCheckDialogPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IViewReference;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.navigator.CommonNavigator;
+import org.eclipse.ui.progress.IProgressConstants;
+
+/**
+ * @author rcernich
+ *
+ * Created on Feb 24, 2004
+ */
+public class ExecuteUndeploymentJob extends Job {
+
+ private Root mRoot;
+ private Map mDeployConfigToDeployTargetMap = new HashMap();
+ private Map mDeployTargetToDeploySessionMap = new HashMap();
+ private Map mDeployStatusMap = new HashMap();
+ private boolean mHasErrorStatus = false;
+ private CreateDeployPackagesJob mCreatePackages;
+ private Shell mShell;
+
+ /**
+ *
+ */
+ public ExecuteUndeploymentJob(Root root, Shell shell) {
+ super(DeployCorePlugin.getDefault().getResourceString(
+ "ExecuteUndeploymentJob.task.name"));
+ mRoot = root;
+ mShell = shell;
+ mCreatePackages = new CreateDeployPackagesJob(mRoot);
+ setRule(ResourcesPlugin.getWorkspace().getRoot());
+ setUser(true);
+ setSystem(false);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public IStatus run(IProgressMonitor monitor) {
+ monitor.beginTask(DeployCorePlugin.getDefault().getResourceString(
+ "ExecuteUndeploymentJob.task.name"), 3000); //$NON-NLS-1$
+
+ mDeployStatusMap.clear();
+ mHasErrorStatus = false;
+
+ IStatus status = Status.OK_STATUS;
+
+ try {
+ Map packageDescriptors = createPackages(monitor);
+
+ preUndeployCheck(packageDescriptors, monitor);
+
+ undeployPackages(packageDescriptors, monitor);
+
+ if (mHasErrorStatus) {
+ status = new Status(Status.ERROR, DeployCorePlugin
+ .getDefault().getBundle().getSymbolicName(), -1,
+ DeployCorePlugin.getDefault().getResourceString(
+ "ExecuteUndeploymentJob.error.job"), null); //$NON-NLS-1$
+ }
+ }
+ catch (CoreException e) {
+ status = e.getStatus();
+ }
+ catch (InterruptedException e) {
+ status = Status.CANCEL_STATUS;
+ }
+ finally {
+ // Clean up an open sessions.
+ for (Iterator it = mDeployTargetToDeploySessionMap.values()
+ .iterator(); it.hasNext();) {
+ IDeploySession session = (IDeploySession) it.next();
+ if (session != null) {
+ try {
+ session.dispose();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ refreshDSE(monitor);
+
+ mDeployConfigToDeployTargetMap.clear();
+ mDeployTargetToDeploySessionMap.clear();
+ }
+
+ logStatus();
+
+ monitor.done();
+
+ setProperty(IProgressConstants.KEEP_PROPERTY, Boolean.TRUE);
+ setProperty(IProgressConstants.ACTION_PROPERTY, new Action(
+ DeployCorePlugin.getDefault().getResourceString(
+ "ExecuteUndeploymentJob.action.name")) { //$NON-NLS-1$
+
+ public void run() {
+ displayStatus();
+ }
+ });
+
+ return status;
+ }
+
+ public Map getDeployStatusMap() {
+ return mDeployStatusMap;
+ }
+
+ private void checkCancelled(IProgressMonitor monitor)
+ throws InterruptedException {
+ if (monitor.isCanceled()) {
+ throw new InterruptedException();
+ }
+ }
+
+ private Map createPackages(IProgressMonitor monitor) throws CoreException,
+ InterruptedException {
+ SubProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1000);
+ IStatus status = mCreatePackages.run(subMonitor);
+ if (status.getSeverity() != IStatus.OK) {
+ throw new CoreException(status);
+ }
+
+ checkCancelled(monitor);
+
+ return mCreatePackages.getPackageDescriptors();
+ }
+
+ private void preUndeployCheck(Map packageDescriptors,
+ final IProgressMonitor monitor) throws CoreException,
+ InterruptedException {
+ int deployTaskLength = getDeployTaskLength();
+ Map deployCheckStatus = new HashMap();
+ int severity = 0;
+
+ for (Iterator it = packageDescriptors.entrySet().iterator(); it
+ .hasNext();) {
+ Map.Entry entry = (Map.Entry) it.next();
+ DeployConfiguration config = (DeployConfiguration) entry.getKey();
+ IPackageOutputDescriptor descriptor = (IPackageOutputDescriptor) entry
+ .getValue();
+
+ monitor
+ .subTask(DeployCorePlugin
+ .getDefault()
+ .getResourceString(
+ "ExecuteDeploymentJob.subtask.preDeployCheck", //$NON-NLS-1$
+ new Object[] {
+ config.getSourcePackage()
+ .getPackageFile(),
+ config.getTargetServer()
+ .getProfileName()}));
+
+ if (descriptor == null) {
+ String exceptionMessage = DeployCorePlugin.getDefault()
+ .getResourceString(
+ "ExecuteDeploymentJob.error.deployError", //$NON-NLS-1$
+ new Object[] {
+ config.getSourcePackage()
+ .getPackageFile(),
+ config.getTargetServer()
+ .getProfileName()});
+ IStatus status = new Status(
+ Status.ERROR,
+ DeployCorePlugin.getDefault().getBundle()
+ .getSymbolicName(),
+ -1,
+ DeployCorePlugin.getDefault().getResourceString(
+ "ExecuteDeploymentJob.error.log.message"), //$NON-NLS-1$
+ new Exception(exceptionMessage));
+ throw new CoreException(new MultiStatus(DeployCorePlugin
+ .getDefault().getBundle().getSymbolicName(), -1,
+ new IStatus[] { status}, DeployCorePlugin
+ .getDefault().getResourceString(
+ "UndeployStatusDialog.TITLE"), //$NON-NLS-1$
+ null));
+ }
+ else {
+ IDeployTarget target = Utilities.adaptToIDeployTarget(config);
+ IDeploySession session = target.createDeploySession();
+
+ mDeployConfigToDeployTargetMap.put(config, target);
+ mDeployTargetToDeploySessionMap.put(target, session);
+
+ IStatus[] status = session.preUndeployCheck(descriptor);
+ deployCheckStatus.put(config, status);
+ if (status != null && status.length > 0) {
+ for (int index = 0, count = status.length; (severity & IStatus.ERROR) == 0
+ && index < count; ++index) {
+ severity |= status[index].getSeverity();
+ }
+ }
+ }
+
+ monitor.worked(deployTaskLength);
+
+ if (severity != 0) {
+ Display display = PlatformUI.getWorkbench().getDisplay();
+ final PreDeployCheckDialogPage page = new PreDeployCheckDialogPage(
+ deployCheckStatus, (severity & IStatus.ERROR) == 0);
+
+ display.syncExec(new Runnable() {
+
+ public void run() {
+ boolean disposeShell = false;
+ Display display = Display.getCurrent();
+ Shell shell = display.getActiveShell();
+ if (shell == null) {
+ Shell shells[] = display.getShells();
+ if (shells.length > 0) {
+ shell = shells[shells.length - 1];
+ }
+ else {
+ disposeShell = true;
+ shell = new Shell();
+ }
+ }
+ try {
+ Dialog dialog = new Dialog(shell, page, SWT.RESIZE);
+ if (dialog.open() == Dialog.CANCEL) {
+ monitor.setCanceled(true);
+ }
+ }
+ finally {
+ if (disposeShell) {
+ shell.dispose();
+ }
+ }
+ }
+ });
+ }
+
+ checkCancelled(monitor);
+ }
+ checkCancelled(monitor);
+ }
+
+ private void undeployPackages(Map packageDescriptors, IProgressMonitor monitor)
+ throws CoreException, InterruptedException {
+ int deployTaskLength = getDeployTaskLength();
+
+ for (Iterator it = packageDescriptors.entrySet().iterator(); it
+ .hasNext();) {
+ Map.Entry entry = (Map.Entry) it.next();
+ DeployConfiguration config = (DeployConfiguration) entry.getKey();
+ IPackageOutputDescriptor descriptor = (IPackageOutputDescriptor) entry
+ .getValue();
+
+ monitor
+ .subTask(DeployCorePlugin
+ .getDefault()
+ .getResourceString(
+ "ExecuteDeploymentJob.subtask.deploy", //$NON-NLS-1$
+ new Object[] {
+ config.getSourcePackage()
+ .getPackageFile(),
+ config.getTargetServer()
+ .getProfileName()}));
+
+ if (descriptor == null
+ || !new File(descriptor.getFileName()).exists()) {
+ mDeployStatusMap.put(config, new IStatus[] { new Status(
+ IStatus.ERROR, DeployCorePlugin.getDefault()
+ .getBundle().getSymbolicName(), -1,
+ DeployCorePlugin.getDefault().getResourceString(
+ "Deploy.ERROR.PackageDoesNotExist", //$NON-NLS-1$
+ new Object[] {
+ config.getSourcePackage()
+ .getPackageFile(),
+ config.getTargetServer()
+ .getProfileName()}), null)});
+ mHasErrorStatus = true;
+ }
+ else {
+ IDeployTarget target = (IDeployTarget) mDeployConfigToDeployTargetMap
+ .get(config);
+ IDeploySession session = (IDeploySession) mDeployTargetToDeploySessionMap
+ .get(target);
+ try {
+ session.undeploy(descriptor);
+ mDeployStatusMap
+ .put(
+ config,
+ new IStatus[] { new Status(
+ IStatus.INFO,
+ DeployCorePlugin.getDefault()
+ .getBundle()
+ .getSymbolicName(),
+ -1,
+ DeployCorePlugin
+ .getDefault()
+ .getResourceString(
+ "Undeploy.SUCCESS.Generic", //$NON-NLS-1$
+ new Object[] {
+ config
+ .getSourcePackage()
+ .getPackageFile(),
+ config
+ .getTargetServer()
+ .getProfileName()}),
+ null)});
+ }
+ catch (Exception e) {
+ mDeployStatusMap
+ .put(
+ config,
+ new IStatus[] { new Status(
+ IStatus.ERROR,
+ DeployCorePlugin.getDefault()
+ .getBundle()
+ .getSymbolicName(),
+ -1,
+ DeployCorePlugin
+ .getDefault()
+ .getResourceString(
+ "Undeploy.ERROR.Generic", //$NON-NLS-1$
+ new Object[] {
+ config
+ .getSourcePackage()
+ .getPackageFile(),
+ target
+ .getConnectionProfile()
+ .getName(),
+ e
+ .getMessage()}),
+ e)});
+ mHasErrorStatus = true;
+ }
+ finally {
+ if (session != null) {
+ session.dispose();
+ }
+ mDeployTargetToDeploySessionMap.remove(target);
+ }
+ }
+ monitor.worked(deployTaskLength);
+
+ checkCancelled(monitor);
+ }
+ checkCancelled(monitor);
+ }
+
+ private void refreshDSE(IProgressMonitor monitor) {
+ IViewPart dseView = null;
+ IWorkbenchWindow[] workbenchWindows = DeployCorePlugin
+ .getDefault().getWorkbench().getWorkbenchWindows();
+
+ // Find the enterprise browser
+ if (workbenchWindows != null) {
+ for (int winIndex = 0, winCount = workbenchWindows.length; dseView == null
+ && winIndex < winCount; ++winIndex) {
+ IWorkbenchPage workbenchPages[] = workbenchWindows[winIndex]
+ .getPages();
+ if (workbenchPages != null) {
+ IViewReference dseReference = null;
+ for (int pageIndex = 0, pageCount = workbenchPages.length; dseReference == null
+ && pageIndex < pageCount; ++pageIndex) {
+ dseReference = workbenchPages[pageIndex]
+ .findViewReference(DSEPlugin.SERVERS_VIEW_VIEWER_ID);
+ }
+ if (dseReference != null) {
+ dseView = dseReference
+ .getView(false);
+ }
+ }
+ }
+ }
+
+ // Refresh the browser
+ if (dseView != null
+ && dseView instanceof CommonNavigator) {
+ int refreshTaskLength = getRefreshTaskLength();
+ final CommonNavigator serversView = (CommonNavigator) dseView;
+ Display display = serversView.getSite().getPage()
+ .getWorkbenchWindow().getShell().getDisplay();
+ final TreeViewer viewer = serversView.getCommonViewer();
+
+ // Bring the enterprise browser to the front
+ display.syncExec(new Runnable() {
+
+ public void run() {
+ serversView.getViewSite().getPage().activate(serversView);
+ }
+ });
+
+ for (Iterator it = mRoot.getServer().iterator(); it.hasNext();) {
+ DeployServer server = (DeployServer) it.next();
+ final IConnectionProfile profile = ProfileManager.getInstance()
+ .getProfileByName(server.getProfileName());
+
+ // Refresh the profile
+ if (profile.isConnected()) {
+ RefreshProfileJob
+ .scheduleRefreshProfileJob(profile, viewer);
+ }
+
+ monitor.worked(refreshTaskLength);
+ }
+ }
+ }
+
+ private int getDeployTaskLength() {
+ int retVal = 0;
+ for (Iterator it = mRoot.getPackage().iterator(); it.hasNext();) {
+ retVal += ((DeployPackage) it.next()).getTargetConfiguration()
+ .size();
+ }
+ return retVal / 1000 + 1;
+ }
+
+ private int getRefreshTaskLength() {
+ return mRoot.getServer().size() / 1000 + 1;
+ }
+
+ private void logStatus() {
+ Collection statuses = new ArrayList();
+ for (Iterator it = mDeployStatusMap.values().iterator(); it.hasNext();) {
+ statuses.addAll(Arrays.asList((IStatus[]) it.next()));
+ }
+ DeployCorePlugin.getDefault().log(
+ new MultiStatus(DeployCorePlugin.getDefault().getBundle()
+ .getSymbolicName(), -1, (IStatus[]) statuses
+ .toArray(new IStatus[statuses.size()]),
+ DeployCorePlugin.getDefault().getResourceString(
+ "UndeployStatusDialog.TITLE"), //$NON-NLS-1$
+ null));
+ }
+
+ private void displayStatus() {
+ Display display = PlatformUI.getWorkbench().getDisplay();
+ final DeployStatusDialogPage page = new DeployStatusDialogPage(
+ mDeployStatusMap);
+
+ display.syncExec(new Runnable() {
+
+ public void run() {
+ boolean disposeShell = false;
+ Display display = Display.getCurrent();
+ Shell shell = mShell;
+ if (shell == null) {
+ Shell shells[] = display.getShells();
+ if (shells.length > 0) {
+ shell = shells[shells.length - 1];
+ }
+ else {
+ disposeShell = true;
+ shell = new Shell();
+ }
+ }
+ try {
+ Dialog dialog = new Dialog(shell, page, SWT.RESIZE);
+ dialog.open();
+ }
+ finally {
+ if (disposeShell) {
+ shell.dispose();
+ }
+ }
+ }
+ });
+ }
+
+}
Index: src/org/eclipse/stp/soas/deploy/core/ui/actions/BasePackageActionDelegate.java
===================================================================
RCS file: src/org/eclipse/stp/soas/deploy/core/ui/actions/BasePackageActionDelegate.java
diff -N src/org/eclipse/stp/soas/deploy/core/ui/actions/BasePackageActionDelegate.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/stp/soas/deploy/core/ui/actions/BasePackageActionDelegate.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2004-2006 Sybase, Inc.
+ *
+ * All rights reserved. This program and the accompanying materials are 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: Sybase, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.stp.soas.deploy.core.ui.actions;
+
+import java.util.Random;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.stp.soas.deploy.core.IPackage;
+import org.eclipse.stp.soas.deploy.core.DeployCorePlugin;
+import org.eclipse.stp.soas.deploy.models.deployfile.DeployConfiguration;
+import org.eclipse.stp.soas.deploy.models.deployfile.DeployFileFactory;
+import org.eclipse.stp.soas.deploy.models.deployfile.DeployPackage;
+import org.eclipse.stp.soas.deploy.models.deployfile.DeployServer;
+import org.eclipse.stp.soas.deploy.models.deployfile.Root;
+import org.eclipse.stp.soas.internal.deploy.ui.dialogs.Dialog;
+import org.eclipse.stp.soas.internal.deploy.ui.dialogs.ServerSelectionDialogPage;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+public abstract class BasePackageActionDelegate implements IObjectActionDelegate {
+
+ private IStructuredSelection mSelection = null;
+
+ /**
+ * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction,
+ * org.eclipse.swt.widgets.Event)
+ */
+ public void runWithEvent(IAction action, Event event) {
+ run(action);
+ }
+
+ /**
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run(Event event) {
+ run((IAction) null);
+ }
+
+ /**
+ * @see IActionDelegate#run(IAction)
+ */
+ public void run(IAction action) {
+ if (mSelection == null
+ || !(mSelection.getFirstElement() instanceof IPackage)) {
+ return;
+ }
+ IPackage thePackage = (IPackage) mSelection.getFirstElement();
+ Root root = DeployFileFactory.eINSTANCE.createRoot();
+ DeployPackage deployPackage = DeployFileFactory.eINSTANCE
+ .createDeployPackage(root, thePackage.getFile()
+ .getProjectRelativePath().toString());
+ DeployConfiguration deployConfig = DeployFileFactory.eINSTANCE
+ .createDeployConfiguration(null, deployPackage);
+
+ ServerSelectionDialogPage page = new ServerSelectionDialogPage();
+ Dialog dialog = new Dialog(DeployCorePlugin.getDefault()
+ .getWorkbench().getActiveWorkbenchWindow().getShell(), page);
+
+ page.init(deployPackage, thePackage, null);
+ if (dialog.open() == Dialog.OK) {
+ ResourceSet rs = new ResourceSetImpl();
+ Resource resource = rs
+ .createResource(createDeployResourceURI(thePackage));
+ DeployServer target = page.getSelectedDeployServer();
+
+ resource.getContents().add(root);
+
+ root.getServer().add(target);
+ deployConfig.setTargetServer(target);
+
+ BaseAction deployAction = getExecuteAction(DeployCorePlugin.getDefault()
+ .getWorkbench().getActiveWorkbenchWindow()
+ .getShell());
+ deployAction.selectionChanged(new StructuredSelection(root));
+ deployAction.run();
+ }
+ }
+
+ protected abstract BaseAction getExecuteAction(Shell shell);
+
+ /**
+ * @see IActionDelegate#selectionChanged(IAction, ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ mSelection = (IStructuredSelection) selection;
+ }
+ }
+
+ private URI createDeployResourceURI(IPackage thePackage) {
+ IPath pkgPath = thePackage.getFile().getFullPath();
+ String pkgName = pkgPath.removeFileExtension().lastSegment();
+ String deployName = pkgName + '_' + Math.abs(new Random().nextInt());
+ IPath deployPath = pkgPath.removeLastSegments(1).append(deployName)
+ .addFileExtension("deploy"); //$NON-NLS-1$
+ return URI.createPlatformResourceURI(deployPath.toString());
+ }
+}
Index: src/org/eclipse/stp/soas/deploy/core/ui/actions/UndeployPackageActionDelegate.java
===================================================================
RCS file: src/org/eclipse/stp/soas/deploy/core/ui/actions/UndeployPackageActionDelegate.java
diff -N src/org/eclipse/stp/soas/deploy/core/ui/actions/UndeployPackageActionDelegate.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/stp/soas/deploy/core/ui/actions/UndeployPackageActionDelegate.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2004-2006 Sybase, Inc.
+ *
+ * All rights reserved. This program and the accompanying materials are 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: Sybase, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.stp.soas.deploy.core.ui.actions;
+
+import org.eclipse.swt.widgets.Shell;
+
+public class UndeployPackageActionDelegate extends BasePackageActionDelegate {
+
+
+ @Override
+ protected BaseAction getExecuteAction(Shell shell) {
+ return new ExecuteUndeployAction(new String(""), shell);
+ }
+}
Index: src/org/eclipse/stp/soas/deploy/core/ui/actions/BaseAction.java
===================================================================
RCS file: src/org/eclipse/stp/soas/deploy/core/ui/actions/BaseAction.java
diff -N src/org/eclipse/stp/soas/deploy/core/ui/actions/BaseAction.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/stp/soas/deploy/core/ui/actions/BaseAction.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2005-2006 Sybase, Inc.
+ *
+ * All rights reserved. This program and the accompanying materials are 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: Sybase, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.stp.soas.deploy.core.ui.actions;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.stp.soas.deploy.models.deployfile.Root;
+import org.eclipse.ui.actions.BaseSelectionListenerAction;
+
+/**
+ * @author rcernich
+ *
+ * Created on Jan 21, 2005
+ */
+public class BaseAction extends BaseSelectionListenerAction {
+
+
+ protected BaseAction(String text) {
+ super(text);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.actions.BaseSelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ protected boolean updateSelection(IStructuredSelection selection) {
+ boolean retVal = super.updateSelection(selection);
+ if (retVal) {
+ setEnabled(selection.size() == 1
+ && selection.getFirstElement() instanceof Root);
+ }
+ return retVal && true;
+ }
+
+ protected Root getSelectedRoot() {
+ return (Root) getStructuredSelection().getFirstElement();
+ }
+}
#P org.eclipse.stp.soas.deploy.tomcat
Index: src/org/eclipse/stp/soas/deploy/tomcat/WarDeployFilePackageConstructor.java
===================================================================
RCS file: /cvsroot/stp/org.eclipse.stp.soas/org.eclipse.stp.soas.deploy.tomcat/src/org/eclipse/stp/soas/deploy/tomcat/WarDeployFilePackageConstructor.java,v
retrieving revision 1.2
diff -u -r1.2 WarDeployFilePackageConstructor.java
--- src/org/eclipse/stp/soas/deploy/tomcat/WarDeployFilePackageConstructor.java 1 Nov 2006 04:08:57 -0000 1.2
+++ src/org/eclipse/stp/soas/deploy/tomcat/WarDeployFilePackageConstructor.java 17 Apr 2007 06:19:09 -0000
@@ -1,6 +1,6 @@
/*******************************************************************************
-* Copyright (c) 2006 IONA Technologies PLC
+* Copyright (c) 2006 IONA Technologies PLCz
* All rights reserved. This program and the accompanying materials
Index: src/org/eclipse/stp/soas/deploy/tomcat/deploydriver/TomcatDeploySession.java
===================================================================
RCS file: /cvsroot/stp/org.eclipse.stp.soas/org.eclipse.stp.soas.deploy.tomcat/src/org/eclipse/stp/soas/deploy/tomcat/deploydriver/TomcatDeploySession.java,v
retrieving revision 1.3
diff -u -r1.3 TomcatDeploySession.java
--- src/org/eclipse/stp/soas/deploy/tomcat/deploydriver/TomcatDeploySession.java 27 Nov 2006 20:30:46 -0000 1.3
+++ src/org/eclipse/stp/soas/deploy/tomcat/deploydriver/TomcatDeploySession.java 17 Apr 2007 06:19:11 -0000
@@ -17,6 +17,7 @@
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
+import org.eclipse.core.internal.utils.FileUtil;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.datatools.connectivity.IConnectionProfile;
@@ -146,5 +147,39 @@
}
}
+ @Override
+ public void undeploy(IPackageOutputDescriptor descriptor) throws Exception {
+ openConnection();
+ File server = (File) mConnection.getRawConnection();
+ File newPackage = new File(server, descriptor.getLogicalName());
+ if(newPackage.exists()){
+ newPackage.delete();
+ }
+ String expandFolderName = getFileNameWithoutExt(newPackage, '.');
+ File expandFolder = new File(server, expandFolderName);
+ if(expandFolder.exists()){
+ expandFolder.delete();
+ }
+
+
+ }
+
+ private static String getFileNameWithoutExt(File file, char split) {
+ String fullName = file.getName();
+ int i = fullName.indexOf(split);
+ int leg = fullName.length();
+ return (i > 0 ? (i + 1) == leg ? "" : fullName.substring(0, i - 1) : "");
+ }
+
+ @Override
+ public IStatus[] preUndeployCheck(IPackageOutputDescriptor descriptor) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IStatus[] preUnDeployCheck(IPackageOutputDescriptor descriptor) {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
#P org.eclipse.stp.soas.deploy.emf
Index: META-INF/MANIFEST.MF
===================================================================
RCS file: /cvsroot/stp/org.eclipse.stp.soas/org.eclipse.stp.soas.deploy.emf/META-INF/MANIFEST.MF,v
retrieving revision 1.2
diff -u -r1.2 MANIFEST.MF
--- META-INF/MANIFEST.MF 12 Feb 2007 11:29:58 -0000 1.2
+++ META-INF/MANIFEST.MF 17 Apr 2007 06:19:21 -0000
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: STP SOAS Deploy EMF Utilities Plug-in
-Bundle-SymbolicName: org.eclipse.stp.soas.deploy.emf
+Bundle-SymbolicName: org.eclipse.stp.soas.deploy.emf;singleton:=true
Bundle-Version: 0.4.0
Bundle-Vendor: Eclipse.org
Bundle-Localization: plugin
Index: plugin.xml
===================================================================
RCS file: plugin.xml
diff -N plugin.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ plugin.xml 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.views">
+ <view
+ class="org.eclipse.stp.soas.deploy.emf.ViewPart6"
+ id="org.eclipse.stp.soas.deploy.emf.view6"
+ name="name">
+ </view>
+ </extension>
+
+</plugin>