[194434] Check for existance of project and EAR at specified location.
diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/DefaultingUtils.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/DefaultingUtils.java
index ec3795d..bba32af 100644
--- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/DefaultingUtils.java
+++ b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/DefaultingUtils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
+ * Copyright (c) 2006, 2007 IBM Corporation and others.
* 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
@@ -10,12 +10,14 @@
* yyyymmdd bug Email and other contact information
* -------- -------- -----------------------------------------------------------
* 20060427 138058 joan@ca.ibm.com - Joan Haggarty
+ * 20070723 194434 kathy@ca.ibm.com - Kathy Chan, Check for non-existing EAR with content not deleted
*******************************************************************************/
package org.eclipse.jst.ws.internal.consumption.ui.common;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
import org.eclipse.jst.ws.internal.common.J2EEUtils;
import org.eclipse.jst.ws.internal.common.ResourceUtils;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
@@ -73,8 +75,27 @@
}
}
+
+ String baseEARName = projectName + ResourceUtils.getDefaultEARExtension();
+ String earName = baseEARName;
+
+ boolean foundEAR = false;
+ int i = 1;
+
+ while (!foundEAR) {
+ // 194434 - Check for non-existing EAR with contents that's not deleted previously
+ IStatus canCreateEARStatus = J2EEUtils.canCreateEAR(ProjectUtilities.getProject(earName));
+ if (canCreateEARStatus.isOK()) {
+ foundEAR = true;
+ } else {
+ earName = baseEARName + i;
+ i++;
+ }
+ }
+
+
//Step 2 - return project name with EAR on the end
- return projectName + ResourceUtils.getDefaultEARExtension();
+ return earName;
}
//Step 3 - return the default EAR project name
diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/ValidationUtils.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/ValidationUtils.java
index f9a39b3..fe9ab22 100644
--- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/ValidationUtils.java
+++ b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/ValidationUtils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
* 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
@@ -19,6 +19,7 @@
* 20060427 138058 joan@ca.ibm.com - Joan Haggarty
* 20060905 156230 kathy@ca.ibm.com - Kathy Chan, Handling projects with no target runtime
* 20070119 159458 mahutch@ca.ibm.com - Mark Hutchinson
+ * 20070723 194434 kathy@ca.ibm.com - Kathy Chan, Check for non-existing EAR with content not deleted
*******************************************************************************/
package org.eclipse.jst.ws.internal.consumption.ui.common;
@@ -410,6 +411,13 @@
if (needEar) {
IProject project = ProjectUtilities.getProject(projectName);
IProject ep = ProjectUtilities.getProject(earProjectName);
+
+ // 194434 - Check for non-existing EAR with contents that's not deleted previously
+ IStatus canCreateEARStatus = J2EEUtils.canCreateEAR(ep);
+ if (!canCreateEARStatus.isOK()) {
+ return canCreateEARStatus;
+ }
+
if (project.exists() && ep.exists()) {
if (!J2EEUtils.isComponentAssociated(ep, project)) {
IStatus associateStatus = J2EEUtils.canAssociateProjectToEAR(project, ep);
diff --git a/bundles/org.eclipse.jst.ws/META-INF/MANIFEST.MF b/bundles/org.eclipse.jst.ws/META-INF/MANIFEST.MF
index e30d7d2..a06fa29 100644
--- a/bundles/org.eclipse.jst.ws/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.jst.ws/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %PLUGIN_NAME
Bundle-SymbolicName: org.eclipse.jst.ws
-Bundle-Version: 1.0.104.qualifier
+Bundle-Version: 1.0.105.qualifier
Bundle-Activator: org.eclipse.jst.ws.internal.plugin.WebServicePlugin
Bundle-Vendor: %PLUGIN_PROVIDER
Bundle-Localization: plugin
diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/J2EEUtils.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/J2EEUtils.java
index e513d73..a20bf41 100644
--- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/J2EEUtils.java
+++ b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/J2EEUtils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
* 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
@@ -13,6 +13,7 @@
* 20060329 128069 rsinha@ca.ibm.com - Rupam Kuehner
* 20060503 126819 rsinha@ca.ibm.com - Rupam Kuehner
* 20060524 131132 mahutch@ca.ibm.com - Mark Hutchinson
+ * 20070723 194434 kathy@ca.ibm.com - Kathy Chan, Check for non-existing EAR with content not deleted
*******************************************************************************/
package org.eclipse.jst.ws.internal.common;
@@ -29,6 +30,7 @@
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
@@ -60,6 +62,7 @@
import org.eclipse.wst.common.environment.ILog;
import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationDataModelProviderNew;
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
import org.eclipse.wst.common.project.facet.core.IProjectFacet;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
@@ -1404,4 +1407,16 @@
return (IFolder)J2EEProjectUtilities.getOutputContainers(component.getProject())[0];
}
+ // 194434 - Check for non-existing EAR with contents that's not deleted previously
+ public static IStatus canCreateEAR(IProject earProject)
+ {
+ IStatus status = Status.OK_STATUS;
+ if( !earProject.exists() ){
+ IPath path = ResourcesPlugin.getWorkspace().getRoot().getLocation();
+ path = path.append(earProject.getName());
+ status = ProjectCreationDataModelProviderNew.validateExisting(earProject.getName(), path.toOSString());
+ }
+ return status;
+ }
+
}