[286868] EJB Projects created by web Service Wizards does not add the ejbModule as a source folder
diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/FacetOperationDelegate.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/FacetOperationDelegate.java
index 2048192..5abbc8c 100644
--- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/FacetOperationDelegate.java
+++ b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/FacetOperationDelegate.java
@@ -10,6 +10,7 @@
* yyyymmdd bug Email and other contact information
* -------- -------- -----------------------------------------------------------
* 20090303 242635 mahutch@ca.ibm.com - Mark Hutchinson, Remove unnecessary UI dependencies from org.eclipse.jst.ws.consumption
+ * 20090819 286874 zina@ca.ibm.com - Zina Mostafia
*******************************************************************************/
package org.eclipse.jst.ws.internal.consumption.ui.common;
@@ -21,12 +22,18 @@
import org.eclipse.core.resources.IProject;
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.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jst.ws.internal.common.J2EEUtils;
import org.eclipse.jst.ws.internal.consumption.ConsumptionMessages;
import org.eclipse.jst.ws.internal.consumption.common.FacetUtils;
import org.eclipse.jst.ws.internal.consumption.common.IFacetOperationDelegate;
@@ -53,6 +60,7 @@
public void run(IProgressMonitor shellMonitor) throws InvocationTargetException, InterruptedException {
try {
fproject.modify(actions, shellMonitor);
+ fixEJBClassPath(fproject);
} catch (CoreException e) {
status[0] = getErrorStatusForAddingFacets(fproject.getProject().getName(), projectFacetVersions, e);
}
@@ -71,6 +79,7 @@
} else {
try {
fproject.modify(actions, null);
+ fixEJBClassPath(fproject);
} catch (CoreException e) {
status[0] = getErrorStatusForAddingFacets(fproject.getProject().getName(), projectFacetVersions, e);
}
@@ -79,6 +88,36 @@
return status[0];
}
+ private void fixEJBClassPath(IFacetedProject project) {
+ if (!J2EEUtils.isEJBComponent(project.getProject())) return;
+ IProject ejbProject = project.getProject();
+ IJavaProject javaProject = JavaCore.create(ejbProject);
+ Path projectRoot = new Path(Path.ROOT.append(new Path(ejbProject.getName())).toString());
+ IPath ejbModulePath = projectRoot.append("ejbModule");
+ try {
+ IClasspathEntry[] originalSet = javaProject.getRawClasspath();
+ boolean foundEJBModulEntry = false;
+ for (IClasspathEntry entry : originalSet) {
+ if (entry.getPath().equals(ejbModulePath))
+ foundEJBModulEntry = true;
+ }
+ if (!foundEJBModulEntry) {
+ IClasspathEntry[] newSet = new IClasspathEntry[originalSet.length + 1];
+ int i=0;
+
+ for (IClasspathEntry entry : originalSet) {
+ newSet[i++] = entry;
+ }
+ newSet[i] = JavaCore.newSourceEntry(ejbModulePath);
+ javaProject.setRawClasspath(newSet,null);
+ }
+ }
+ catch (Exception e) {
+ // TODO: handle exception
+ }
+
+ }
+
public IStatus createNewFacetedProject(final String projectName) {
final IStatus[] status = new IStatus[1];
status[0] = Status.OK_STATUS;