Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 206086
Collapse All | Expand All

(-)archiveops/org/eclipse/jst/j2ee/internal/archive/ArchiveWrapper.java (-20 / +46 lines)
Lines 28-33 Link Here
28
import org.eclipse.jst.j2ee.ejb.EJBJar;
28
import org.eclipse.jst.j2ee.ejb.EJBJar;
29
import org.eclipse.jst.j2ee.internal.J2EEConstants;
29
import org.eclipse.jst.j2ee.internal.J2EEConstants;
30
import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
30
import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
31
import org.eclipse.jst.j2ee.internal.archive.operations.EARArchiveOpsResourceHandler;
31
import org.eclipse.jst.javaee.application.Application;
32
import org.eclipse.jst.javaee.application.Application;
32
import org.eclipse.jst.javaee.application.Module;
33
import org.eclipse.jst.javaee.application.Module;
33
import org.eclipse.jst.jee.archive.ArchiveModelLoadException;
34
import org.eclipse.jst.jee.archive.ArchiveModelLoadException;
Lines 38-43 Link Here
38
39
39
public class ArchiveWrapper {
40
public class ArchiveWrapper {
40
41
42
	//TODO remove commonArchive; possibly remove this entire class and
43
	//code directly to IArchive
41
	private Archive commonArchive = null;
44
	private Archive commonArchive = null;
42
	private IArchive archive = null;
45
	private IArchive archive = null;
43
	private JavaEEQuickPeek jqp = null;
46
	private JavaEEQuickPeek jqp = null;
Lines 333-346 Link Here
333
		if (archive != null) {
336
		if (archive != null) {
334
			IArchive earArchive = archive.getArchive();
337
			IArchive earArchive = archive.getArchive();
335
			if(earArchive.containsArchiveResource(new Path(J2EEConstants.APPLICATION_DD_URI))){
338
			if(earArchive.containsArchiveResource(new Path(J2EEConstants.APPLICATION_DD_URI))){
336
				Application application;
339
				JavaEEQuickPeek earJQP = JavaEEArchiveUtilities.INSTANCE.getJavaEEQuickPeek(earArchive);
337
				try {
340
				if(earJQP.getJavaEEVersion() == JavaEEQuickPeek.JEE_5_0_ID){
338
					application = (Application) earArchive.getModelObject();
341
					try {
339
					String moduleName = archive.getPath().toString();
342
						Application application = (Application) earArchive.getModelObject();
340
					Module module = (Module) application.getFirstModule(moduleName);
343
						String moduleName = archive.getPath().toString();
341
					cachedWebContextRoot[0] = module.getWeb().getContextRoot();				
344
						Module module = (Module) application.getFirstModule(moduleName);
342
				} catch (ArchiveModelLoadException e) {
345
						cachedWebContextRoot[0] = module.getWeb().getContextRoot();				
343
					Logger.getLogger().logError(e);
346
					} catch (ArchiveModelLoadException e) {
347
						Logger.getLogger().logError(e);
348
					}
349
				} else {
350
					try{
351
						org.eclipse.jst.j2ee.application.Application application = (org.eclipse.jst.j2ee.application.Application)earArchive.getModelObject();
352
						String moduleName = archive.getPath().toString();
353
						org.eclipse.jst.j2ee.application.WebModule module = (org.eclipse.jst.j2ee.application.WebModule)application.getFirstModule(moduleName);
354
						if(module == null){
355
							cachedWebContextRoot[0] = null;
356
						} else {
357
							cachedWebContextRoot[0] = module.getContextRoot();
358
						}
359
					} catch (ArchiveModelLoadException e) {
360
						Logger.getLogger().logError(e);
361
					}
344
				}
362
				}
345
			} else {
363
			} else {
346
				//J2EE spec 8.3.1.3.c (pg 149)
364
				//J2EE spec 8.3.1.3.c (pg 149)
Lines 386-414 Link Here
386
		if (archive != null) {
404
		if (archive != null) {
387
			try {
405
			try {
388
				JavaEEQuickPeek jqp = JavaEEArchiveUtilities.INSTANCE.getJavaEEQuickPeek(ejbWrapper.archive);
406
				JavaEEQuickPeek jqp = JavaEEArchiveUtilities.INSTANCE.getJavaEEQuickPeek(ejbWrapper.archive);
389
				String clientJar = null;
407
				String clientJarName = null;
390
				if(jqp.getVersion() == J2EEVersionConstants.EJB_3_0_ID){
408
				if(jqp.getVersion() == J2EEVersionConstants.EJB_3_0_ID){
391
					if(ejbWrapper.archive.containsArchiveResource(new Path(J2EEConstants.EJBJAR_DD_URI))){
409
					if(ejbWrapper.archive.containsArchiveResource(new Path(J2EEConstants.EJBJAR_DD_URI))){
392
						org.eclipse.jst.javaee.ejb.EJBJar edd = (org.eclipse.jst.javaee.ejb.EJBJar) ejbWrapper.archive.getModelObject();
410
						org.eclipse.jst.javaee.ejb.EJBJar edd = (org.eclipse.jst.javaee.ejb.EJBJar) ejbWrapper.archive.getModelObject();
393
						clientJar = edd.getEjbClientJar();
411
						clientJarName = edd.getEjbClientJar();
394
					}
412
					}
395
				} else {
413
				} else {
396
					EJBJar jar = (EJBJar)ejbWrapper.archive.getModelObject();
414
					EJBJar jar = (EJBJar)ejbWrapper.archive.getModelObject();
397
					if (jar != null) {
415
					if (jar != null) {
398
						clientJar = jar.getEjbClientJar();
416
						clientJarName = jar.getEjbClientJar();
399
					}
417
					}
400
				}
418
				}
401
				
419
				
402
				if (null != clientJar) {
420
				if (null != clientJarName) {
403
					IArchiveResource ar = archive.getArchiveResource(new Path(clientJar));
421
					IPath clientJarPath = new Path(clientJarName);
404
					if (ar.getType() == IArchiveResource.ARCHIVE_TYPE) {
422
					if(archive.containsArchiveResource(clientJarPath)){
405
						cachedEJBClientArchiveWrapper[0] = new ArchiveWrapper((IArchive) ar);
423
						IArchiveResource clientJar = archive.getArchiveResource(clientJarPath);
406
					} else {
424
						if(null != clientJar){
407
						try {
425
							if (clientJar.getType() == IArchiveResource.ARCHIVE_TYPE) {
408
							cachedEJBClientArchiveWrapper[0] = new ArchiveWrapper(archive.getNestedArchive(ar));
426
								cachedEJBClientArchiveWrapper[0] = new ArchiveWrapper((IArchive) clientJar);
409
						} catch (ArchiveOpenFailureException e) {
427
							} else {
410
							Logger.getLogger().logError(e);
428
								try {
429
									cachedEJBClientArchiveWrapper[0] = new ArchiveWrapper(archive.getNestedArchive(clientJar));
430
								} catch (ArchiveOpenFailureException e) {
431
									Logger.getLogger().logError(e);
432
								}
433
							}
411
						}
434
						}
435
					} else {
436
						Logger.getLogger().logWarning(EARArchiveOpsResourceHandler.bind(EARArchiveOpsResourceHandler.MISSING_CLIENT_JAR, new Object[] {clientJarName, ejbWrapper.getName(), archive.getPath()}));
412
					}
437
					}
413
				}
438
				}
414
				return cachedEJBClientArchiveWrapper[0];
439
				return cachedEJBClientArchiveWrapper[0];
Lines 475-478 Link Here
475
		fail();
500
		fail();
476
		return null;
501
		return null;
477
	}
502
	}
503
	
478
}
504
}
(-)archiveops/org/eclipse/jst/j2ee/internal/archive/J2EEComponentArchiveSaveAdapter.java (-7 lines)
Lines 141-153 Link Here
141
		return super.getProjectRelativePath(aFile);
141
		return super.getProjectRelativePath(aFile);
142
	}
142
	}
143
	
143
	
144
	protected IPath getOutputPathForFile(IArchiveResource aFile) {
145
		if (endsWithClassType(aFile.getPath().lastSegment())) {
146
			return importedClassesFolder.getFile(getImportedClassesURI(aFile)).getProjectRelativePath();
147
		}
148
		return super.getProjectRelativePath(aFile);
149
	}
150
151
	protected IPath getImportedClassesURI(IArchiveResource aFile) {
144
	protected IPath getImportedClassesURI(IArchiveResource aFile) {
152
		return aFile.getPath();
145
		return aFile.getPath();
153
	}
146
	}
(-)archiveops/org/eclipse/jst/j2ee/internal/archive/JavaEEEMFArchiveAdapterHelper.java (+1 lines)
Lines 185-190 Link Here
185
						if (isTranslator) {
185
						if (isTranslator) {
186
							try {
186
							try {
187
								Constructor constructor = resourceFactory.getClass().getConstructor(RendererFactory.class);
187
								Constructor constructor = resourceFactory.getClass().getConstructor(RendererFactory.class);
188
								EMF2SAXRendererFactory.INSTANCE.setValidating(false);
188
								resourceFactory = (Resource.Factory) constructor.newInstance(EMF2SAXRendererFactory.INSTANCE);
189
								resourceFactory = (Resource.Factory) constructor.newInstance(EMF2SAXRendererFactory.INSTANCE);
189
							} catch (SecurityException e) {
190
							} catch (SecurityException e) {
190
								ArchiveUtil.warn(e);
191
								ArchiveUtil.warn(e);
(-)archiveops/org/eclipse/jst/j2ee/internal/archive/WebComponentArchiveSaveAdapter.java (-25 / +49 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jst.j2ee.internal.archive;
11
package org.eclipse.jst.j2ee.internal.archive;
12
12
13
import java.io.FileNotFoundException;
14
import java.util.HashMap;
13
import java.util.Map;
15
import java.util.Map;
14
16
15
import org.eclipse.core.resources.IFile;
17
import org.eclipse.core.resources.IFile;
Lines 17-29 Link Here
17
import org.eclipse.core.runtime.Path;
19
import org.eclipse.core.runtime.Path;
18
import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveConstants;
20
import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveConstants;
19
import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil;
21
import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil;
20
import org.eclipse.jst.jee.archive.IArchive;
22
import org.eclipse.jst.jee.archive.IArchiveResource;
21
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
23
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
22
import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
24
import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
23
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
25
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
24
26
25
public class WebComponentArchiveSaveAdapter extends J2EEComponentArchiveSaveAdapter {
27
public class WebComponentArchiveSaveAdapter extends J2EEComponentArchiveSaveAdapter {
26
28
29
	private IPath IMPORTED_CLASSES_PATH = new Path("/" + ArchiveConstants.WEBAPP_CLASSES_URI);
30
	
27
	public WebComponentArchiveSaveAdapter(IVirtualComponent vComponent) {
31
	public WebComponentArchiveSaveAdapter(IVirtualComponent vComponent) {
28
		super(vComponent);
32
		super(vComponent);
29
	}
33
	}
Lines 32-67 Link Here
32
		return false; // never add to classpath because the web app container will pick this up.
36
		return false; // never add to classpath because the web app container will pick this up.
33
	}
37
	}
34
38
35
	protected String getImportedClassesURI(IArchive aFile){
39
	protected IPath getImportedClassesURI(IArchiveResource aFile){
36
		return aFile.getPath().lastSegment().toString();
40
		return aFile.getPath().makeRelative().removeFirstSegments(IMPORTED_CLASSES_PATH.segmentCount());
37
		
38
	}
41
	}
39
42
40
	protected IPath getImportedClassesRuntimePath() {
43
	protected IPath getImportedClassesRuntimePath() {
41
		return new Path("/" + ArchiveConstants.WEBAPP_CLASSES_URI);
44
		return IMPORTED_CLASSES_PATH;
42
	}
45
	}
43
46
	
44
	protected IPath getOutputPathForFile(IArchive aFile) {
47
	protected IPath getProjectRelativePath(IArchiveResource aFile) {
45
		if (null != nonStandardSourceFiles && nonStandardSourceFiles.containsKey(aFile)) {
48
		if (null != nonStandardSourceFiles && nonStandardSourceFiles.containsKey(aFile)) {
49
			IPath path = nonStandardSourceFiles.get(aFile);
46
			IVirtualFolder rootFolder = vComponent.getRootFolder();
50
			IVirtualFolder rootFolder = vComponent.getRootFolder();
47
			IVirtualFile vFile = rootFolder.getFile((String) nonStandardSourceFiles.get(aFile));
51
			IVirtualFile vFile = rootFolder.getFile(path);
48
			IFile iFile = vFile.getUnderlyingFile();
52
			IFile iFile = vFile.getUnderlyingFile();
49
			return iFile.getProjectRelativePath();
53
			return iFile.getProjectRelativePath();
50
		}
54
		}
51
		return super.getOutputPathForFile(aFile);
55
		return super.getProjectRelativePath(aFile);
52
	}
56
	}
53
57
54
	/**
58
	/**
55
	 * This map handles the case when a java source file is not in the same place as the .class
59
	 * This map handles the case when a java source file is not in the same place as the .class
56
	 * file. For example if all the source files were contained in WEB-INF/source
60
	 * file. For example if all the source files were contained in WEB-INF/source
57
	 */
61
	 */
58
	protected Map nonStandardSourceFiles;
62
	protected Map<IArchiveResource, IPath> nonStandardSourceFiles;
59
63
60
	protected boolean isClassWithoutSource(IArchive aFile) {
64
	protected boolean isClassWithoutSource(IArchiveResource aFile) {
61
		String javaUri = ArchiveUtil.classUriToJavaUri(aFile.getPath().toString());
65
		String javaUri = ArchiveUtil.classUriToJavaUri(aFile.getPath().toString());
62
		if (javaUri == null)
66
		if (javaUri == null)
63
			return false;
67
			return true;
64
		if (archive.containsArchiveResource(aFile.getPath())) {
68
		IPath javaPath = new Path(javaUri);
69
		if (archive.containsArchiveResource(javaPath)) {
65
			return false;
70
			return false;
66
		}
71
		}
67
		// see if it is a JSP
72
		// see if it is a JSP
Lines 70-91 Link Here
70
		int _index = lastSlash == -1 ? ArchiveConstants.WEBAPP_CLASSES_URI.length() : lastSlash + 1;
75
		int _index = lastSlash == -1 ? ArchiveConstants.WEBAPP_CLASSES_URI.length() : lastSlash + 1;
71
		if (jspUri.charAt(_index) == '_') {
76
		if (jspUri.charAt(_index) == '_') {
72
			jspUri = jspUri.substring(ArchiveConstants.WEBAPP_CLASSES_URI.length(), _index) + jspUri.substring(_index + 1) + ArchiveUtil.DOT_JSP;
77
			jspUri = jspUri.substring(ArchiveConstants.WEBAPP_CLASSES_URI.length(), _index) + jspUri.substring(_index + 1) + ArchiveUtil.DOT_JSP;
73
			if (archive.containsArchiveResource(aFile.getPath())) {
78
			IPath jspPath = new Path(jspUri);
79
			if (archive.containsArchiveResource(jspPath)) {
74
				return false;
80
				return false;
75
			}
81
			}
76
		}
82
		}
77
83
78
		// see if the source is in another directory
84
		//This is to handle archives created by an earlier version
79
		/*File sourceFile = ((WARFile) archive).getSourceFile(aFile);
85
		//The format was to include the source files in a directory called source in WEB-INF
80
		if (null == sourceFile) {
86
		//Example: class  is in WEB-INF/classes/test/Foo.class
81
			return true;
87
		//         source is in WEB-INF/source/test/Foo.java
82
		}*/
88
		if(javaPath.segmentCount() > 2 && javaPath.segment(0).equals("WEB-INF") && javaPath.segment(1).equals("classes")){
83
		/*if (nonStandardSourceFiles == null) {
89
			String alternateJavaUri = javaUri.replaceFirst("classes", "source");
84
			nonStandardSourceFiles = new HashMap();
90
			IPath alternateJavaPath = new Path(alternateJavaUri);
91
			if (archive.containsArchiveResource(alternateJavaPath)){
92
				IArchiveResource sourceFile;
93
				try {
94
					sourceFile = archive.getArchiveResource(alternateJavaPath);
95
					if(sourceFile != null){
96
						if (nonStandardSourceFiles == null) {
97
							nonStandardSourceFiles = new HashMap<IArchiveResource, IPath>();
98
						}
99
						if (!nonStandardSourceFiles.containsKey(sourceFile)) {
100
							nonStandardSourceFiles.put(sourceFile, javaPath);
101
						}
102
						return false;
103
					}
104
				} catch (FileNotFoundException e) {
105
					// TODO Auto-generated catch block
106
					e.printStackTrace();
107
				}
108
				
109
			}
110
			
85
		}
111
		}
86
		if (!nonStandardSourceFiles.containsKey(sourceFile)) {
112
		
87
			nonStandardSourceFiles.put(sourceFile, javaUri);
113
		return true;
88
		}*/
89
		return false;
90
	}
114
	}
91
}
115
}
(-)earproject/org/eclipse/jst/j2ee/application/internal/operations/EARComponentImportDataModelProvider.java (-3 / +16 lines)
Lines 158-164 Link Here
158
		if (NESTED_MODULE_ROOT.equals(propertyName)) {
158
		if (NESTED_MODULE_ROOT.equals(propertyName)) {
159
			updateModuleRoot();
159
			updateModuleRoot();
160
		} else if (FILE_NAME.equals(propertyName)) {
160
		} else if (FILE_NAME.equals(propertyName)) {
161
			setProperty(MODULE_MODELS_LIST, getModuleModels());
161
			List nestedModels = getModuleModels();
162
			setProperty(MODULE_MODELS_LIST, nestedModels);
162
			updateModuleRoot();
163
			updateModuleRoot();
163
			setProperty(UTILITY_LIST, null);
164
			setProperty(UTILITY_LIST, null);
164
165
Lines 168-175 Link Here
168
				IDataModel earFacetDataModel = map.getFacetDataModel(J2EEProjectUtilities.ENTERPRISE_APPLICATION);
169
				IDataModel earFacetDataModel = map.getFacetDataModel(J2EEProjectUtilities.ENTERPRISE_APPLICATION);
169
170
170
				JavaEEQuickPeek quickPeek = getArchiveWrapper().getJavaEEQuickPeek();
171
				JavaEEQuickPeek quickPeek = getArchiveWrapper().getJavaEEQuickPeek();
171
				int version = quickPeek.getVersion();
172
				int minimumVersion = quickPeek.getVersion();
172
				String versionText = J2EEVersionUtil.getJ2EETextVersion(version);
173
				if(nestedModels != null){
174
					//increase the JavaEE facet version to accommodate the highest module version
175
					for(int i=0;i<nestedModels.size(); i++){
176
						IDataModel nestedModel = (IDataModel)nestedModels.get(i);
177
						ArchiveWrapper nestedWrapper = (ArchiveWrapper)nestedModel.getProperty(ARCHIVE_WRAPPER);
178
						int nestedEEVersion = nestedWrapper.getJavaEEQuickPeek().getJavaEEVersion();
179
						if(nestedEEVersion > minimumVersion){
180
							minimumVersion = nestedEEVersion;
181
						}
182
					}
183
				}
184
				
185
				String versionText = J2EEVersionUtil.getJ2EETextVersion(minimumVersion);
173
				earFacetDataModel.setStringProperty(IFacetDataModelProperties.FACET_VERSION_STR, versionText);
186
				earFacetDataModel.setStringProperty(IFacetDataModelProperties.FACET_VERSION_STR, versionText);
174
			}
187
			}
175
188
(-)earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEArtifactImportDataModelProvider.java (-26 / +10 lines)
Lines 198-230 Link Here
198
198
199
	protected ArchiveWrapper openArchiveWrapper(String uri) throws OpenFailureException, ArchiveOpenFailureException{
199
	protected ArchiveWrapper openArchiveWrapper(String uri) throws OpenFailureException, ArchiveOpenFailureException{
200
		IArchive archive = null;
200
		IArchive archive = null;
201
		boolean isEE5 = false;
201
		IPath path = new Path(uri);
202
		try{
202
		archive = JavaEEArchiveUtilities.INSTANCE.openArchive(path);
203
			IPath path = new Path(uri);
203
		archive.getArchiveOptions().setOption(JavaEEArchiveUtilities.DISCRIMINATE_EJB_ANNOTATIONS, Boolean.TRUE);
204
			archive = JavaEEArchiveUtilities.INSTANCE.openArchive(path);
204
		archive.setPath(path);
205
			archive.getArchiveOptions().setOption(JavaEEArchiveUtilities.DISCRIMINATE_EJB_ANNOTATIONS, Boolean.TRUE);
205
		JavaEEQuickPeek jqp = JavaEEArchiveUtilities.INSTANCE.getJavaEEQuickPeek(archive);
206
			archive.setPath(path);
206
		
207
			JavaEEQuickPeek jqp = JavaEEArchiveUtilities.INSTANCE.getJavaEEQuickPeek(archive);
207
		if(jqp.getJavaEEVersion() == J2EEConstants.UNKNOWN && jqp.getType() == J2EEConstants.UNKNOWN){
208
			
208
			handleUnknownType(jqp);
209
			if(jqp.getJavaEEVersion() == J2EEConstants.UNKNOWN && jqp.getType() == J2EEConstants.UNKNOWN){
210
				handleUnknownType(jqp);
211
			}
212
			
213
			if(jqp.getJavaEEVersion() == J2EEConstants.JEE_5_0_ID){
214
				isEE5 = true;
215
				return new ArchiveWrapper(archive);
216
			} else {
217
				Archive commonArchive = openArchive(uri);
218
				if (null != commonArchive) {
219
					commonArchive.setSaveFilter(getSaveFilter());
220
				}
221
				return new ArchiveWrapper(commonArchive);
222
			}
223
		} finally {
224
			if(!isEE5){
225
				JavaEEArchiveUtilities.INSTANCE.closeArchive(archive);
226
			}
227
		}
209
		}
210
		
211
		return new ArchiveWrapper(archive);
228
	}
212
	}
229
	/**
213
	/**
230
	 * This method allows subclasses to handle an unknown archive type.
214
	 * This method allows subclasses to handle an unknown archive type.
(-)earproject/org/eclipse/jst/j2ee/application/internal/operations/AddComponentToEnterpriseApplicationOp.java (-1 / +2 lines)
Lines 29-34 Link Here
29
import org.eclipse.jem.util.UIContextDetermination;
29
import org.eclipse.jem.util.UIContextDetermination;
30
import org.eclipse.jem.util.logger.proxy.Logger;
30
import org.eclipse.jem.util.logger.proxy.Logger;
31
import org.eclipse.jst.j2ee.internal.J2EEConstants;
31
import org.eclipse.jst.j2ee.internal.J2EEConstants;
32
import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
32
import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater;
33
import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater;
33
import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
34
import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
34
import org.eclipse.jst.j2ee.model.IEARModelProvider;
35
import org.eclipse.jst.j2ee.model.IEARModelProvider;
Lines 154-160 Link Here
154
		ICommonModule newModule = null;
155
		ICommonModule newModule = null;
155
		final IVirtualComponent ear = (IVirtualComponent) this.model.getProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT);
156
		final IVirtualComponent ear = (IVirtualComponent) this.model.getProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT);
156
		final IProject earpj = ear.getProject();
157
		final IProject earpj = ear.getProject();
157
		boolean useNewModel = J2EEProjectUtilities.isJEEProject(earpj);
158
		boolean useNewModel = J2EEProjectUtilities.getJ2EEDDProjectVersion(earpj).equals(J2EEVersionConstants.VERSION_5_0_TEXT);
158
		if (J2EEProjectUtilities.isDynamicWebProject(wc.getProject())) {
159
		if (J2EEProjectUtilities.isDynamicWebProject(wc.getProject())) {
159
			Properties props = wc.getMetaProperties();
160
			Properties props = wc.getMetaProperties();
160
			String contextroot = ""; //$NON-NLS-1$
161
			String contextroot = ""; //$NON-NLS-1$
(-)archiveops/org/eclipse/jst/j2ee/internal/archive/operations/J2EEArtifactImportOperation.java (-2 / +5 lines)
Lines 24-29 Link Here
24
import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentImportDataModelProperties;
24
import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentImportDataModelProperties;
25
import org.eclipse.jst.j2ee.internal.archive.ArchiveWrapper;
25
import org.eclipse.jst.j2ee.internal.archive.ArchiveWrapper;
26
import org.eclipse.jst.j2ee.internal.archive.ComponentArchiveSaveAdapter;
26
import org.eclipse.jst.j2ee.internal.archive.ComponentArchiveSaveAdapter;
27
import org.eclipse.jst.j2ee.internal.archive.ConnectorComponentArchiveSaveAdapter;
27
import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater;
28
import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater;
28
import org.eclipse.jst.j2ee.internal.project.ProjectSupportResourceHandler;
29
import org.eclipse.jst.j2ee.internal.project.ProjectSupportResourceHandler;
29
import org.eclipse.jst.jee.archive.ArchiveOptions;
30
import org.eclipse.jst.jee.archive.ArchiveOptions;
Lines 85-91 Link Here
85
	 * @throws ExecutionException
86
	 * @throws ExecutionException
86
	 */
87
	 */
87
	protected void doExecute(IProgressMonitor monitor) throws ExecutionException {
88
	protected void doExecute(IProgressMonitor monitor) throws ExecutionException {
88
		virtualComponent = createVirtualComponent(model.getNestedModel(IJ2EEComponentImportDataModelProperties.NESTED_MODEL_J2EE_COMPONENT_CREATION), new SubProgressMonitor(monitor, PROJECT_CREATION_WORK));
89
		IDataModel nestedModel = model.getNestedModel(IJ2EEComponentImportDataModelProperties.NESTED_MODEL_J2EE_COMPONENT_CREATION);
90
		IProgressMonitor subMonitor = new SubProgressMonitor(monitor, PROJECT_CREATION_WORK);
91
		virtualComponent = createVirtualComponent(nestedModel, subMonitor);
89
92
90
		try {
93
		try {
91
			importModuleFile(new SubProgressMonitor(monitor, archiveWrapper.getSize()));
94
			importModuleFile(new SubProgressMonitor(monitor, archiveWrapper.getSize()));
Lines 117-123 Link Here
117
	}
120
	}
118
	
121
	
119
	protected ComponentArchiveSaveAdapter getArchiveSaveAdapter(IVirtualComponent virtualComponent){
122
	protected ComponentArchiveSaveAdapter getArchiveSaveAdapter(IVirtualComponent virtualComponent){
120
		return null;
123
		return new ConnectorComponentArchiveSaveAdapter(virtualComponent);
121
	}
124
	}
122
125
123
	/**
126
	/**
(-)archiveops/org/eclipse/jst/j2ee/internal/archive/operations/EARArchiveOpsResourceHandler.java (-1 / +2 lines)
Lines 15-21 Link Here
15
public final class EARArchiveOpsResourceHandler extends NLS {
15
public final class EARArchiveOpsResourceHandler extends NLS {
16
16
17
	private static final String BUNDLE_NAME = "eararchiveops";//$NON-NLS-1$
17
	private static final String BUNDLE_NAME = "eararchiveops";//$NON-NLS-1$
18
18
	
19
	private EARArchiveOpsResourceHandler() {
19
	private EARArchiveOpsResourceHandler() {
20
		// Do not instantiate
20
		// Do not instantiate
21
	}
21
	}
Lines 40-45 Link Here
40
	public static String _jar_UI_;
40
	public static String _jar_UI_;
41
	public static String Updating_manifest_Class_Path__attributes_UI_;
41
	public static String Updating_manifest_Class_Path__attributes_UI_;
42
	public static String _preDeploy_ERROR_;
42
	public static String _preDeploy_ERROR_;
43
	public static String MISSING_CLIENT_JAR;
43
44
44
	static {
45
	static {
45
		NLS.initializeMessages(BUNDLE_NAME, EARArchiveOpsResourceHandler.class);
46
		NLS.initializeMessages(BUNDLE_NAME, EARArchiveOpsResourceHandler.class);
(-)archiveops/org/eclipse/jst/j2ee/internal/archive/operations/EARComponentImportOperation.java (-4 / +3 lines)
Lines 22-29 Link Here
22
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.core.runtime.IStatus;
23
import org.eclipse.core.runtime.SubProgressMonitor;
23
import org.eclipse.core.runtime.SubProgressMonitor;
24
import org.eclipse.jem.util.logger.proxy.Logger;
24
import org.eclipse.jem.util.logger.proxy.Logger;
25
import org.eclipse.jst.j2ee.application.internal.operations.AddComponentToEnterpriseApplicationDataModelProvider;
26
import org.eclipse.jst.j2ee.application.internal.operations.IAddComponentToEnterpriseApplicationDataModelProperties;
27
import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
25
import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
28
import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveConstants;
26
import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveConstants;
29
import org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.SaveStrategy;
27
import org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.SaveStrategy;
Lines 36-41 Link Here
36
import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetProjectCreationDataModelProperties;
34
import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetProjectCreationDataModelProperties;
37
import org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties;
35
import org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties;
38
import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties;
36
import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties;
37
import org.eclipse.wst.common.componentcore.internal.operation.CreateReferenceComponentsDataModelProvider;
39
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
38
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
40
import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
39
import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
41
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
40
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
Lines 142-151 Link Here
142
				componentToURIMap.put(component, nestedArchive.getPath().toString());
141
				componentToURIMap.put(component, nestedArchive.getPath().toString());
143
			}
142
			}
144
			if (componentToAdd.size() > 0) {
143
			if (componentToAdd.size() > 0) {
145
				IDataModel addComponentsDM = DataModelFactory.createDataModel(new AddComponentToEnterpriseApplicationDataModelProvider());
144
				IDataModel addComponentsDM = DataModelFactory.createDataModel(new CreateReferenceComponentsDataModelProvider());
146
				addComponentsDM.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, virtualComponent);
145
				addComponentsDM.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, virtualComponent);
147
				addComponentsDM.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, componentToAdd);
146
				addComponentsDM.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, componentToAdd);
148
				addComponentsDM.setProperty(IAddComponentToEnterpriseApplicationDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, componentToURIMap);
147
				addComponentsDM.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, componentToURIMap);
149
				addComponentsDM.getDefaultOperation().execute(new SubProgressMonitor(monitor, LINK_COMPONENTS_WORK), info);
148
				addComponentsDM.getDefaultOperation().execute(new SubProgressMonitor(monitor, LINK_COMPONENTS_WORK), info);
150
			}
149
			}
151
		} finally {
150
		} finally {
(-)earproject/org/eclipse/jst/j2ee/componentcore/util/EARVirtualComponent.java (+2 lines)
Lines 102-107 Link Here
102
								} else {
102
								} else {
103
									if (referencedIVirtualComponent.isBinary()) {
103
									if (referencedIVirtualComponent.isBinary()) {
104
										archiveName = getJarURI(referencedComponent, referencedIVirtualComponent);
104
										archiveName = getJarURI(referencedComponent, referencedIVirtualComponent);
105
									} else if(referencedComponent.getArchiveName() != null){
106
										archiveName = referencedComponent.getArchiveName();
105
									} else {
107
									} else {
106
										IProject referencedProject = referencedIVirtualComponent.getProject();
108
										IProject referencedProject = referencedIVirtualComponent.getProject();
107
										// If dependent object is not set, assume
109
										// If dependent object is not set, assume
(-)j2eecreation/org/eclipse/jst/j2ee/internal/project/J2EEProjectUtilities.java (+73 lines)
Lines 74-85 Link Here
74
import org.eclipse.jst.j2ee.project.facet.IJavaProjectMigrationDataModelProperties;
74
import org.eclipse.jst.j2ee.project.facet.IJavaProjectMigrationDataModelProperties;
75
import org.eclipse.jst.j2ee.project.facet.JavaProjectMigrationDataModelProvider;
75
import org.eclipse.jst.j2ee.project.facet.JavaProjectMigrationDataModelProvider;
76
import org.eclipse.jst.j2ee.project.facet.JavaProjectMigrationOperation;
76
import org.eclipse.jst.j2ee.project.facet.JavaProjectMigrationOperation;
77
import org.eclipse.jst.jee.util.internal.JavaEEQuickPeek;
77
import org.eclipse.jst.server.core.FacetUtil;
78
import org.eclipse.jst.server.core.FacetUtil;
78
import org.eclipse.wst.common.componentcore.ComponentCore;
79
import org.eclipse.wst.common.componentcore.ComponentCore;
79
import org.eclipse.wst.common.componentcore.internal.impl.ModuleURIUtil;
80
import org.eclipse.wst.common.componentcore.internal.impl.ModuleURIUtil;
80
import org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities;
81
import org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities;
81
import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
82
import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
82
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
83
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
84
import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
83
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
85
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
84
import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
86
import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
85
import org.eclipse.wst.common.componentcore.resources.IVirtualResource;
87
import org.eclipse.wst.common.componentcore.resources.IVirtualResource;
Lines 714-719 Link Here
714
		}
716
		}
715
		return ""; //$NON-NLS-1$
717
		return ""; //$NON-NLS-1$
716
	}
718
	}
719
	/**
720
	 * Returns the J2EE Module version based on the DD XML file
721
	 * @param project
722
	 * @return version String
723
	 */
724
	public static String getJ2EEDDProjectVersion(IProject project) {
725
		int type = J2EEVersionConstants.UNKNOWN;
726
		String ddURI = null;
727
		if (J2EEProjectUtilities.isEARProject(project)) {
728
			type = J2EEVersionConstants.APPLICATION_TYPE;
729
			ddURI = J2EEConstants.APPLICATION_DD_URI;
730
		} else if (J2EEProjectUtilities.isEJBProject(project)) {
731
			type = J2EEVersionConstants.EJB_TYPE;
732
			ddURI = J2EEConstants.EJBJAR_DD_URI;
733
		} else if (J2EEProjectUtilities.isApplicationClientProject(project)) {
734
			type = J2EEVersionConstants.APPLICATION_CLIENT_TYPE;
735
			ddURI = J2EEConstants.APP_CLIENT_DD_URI;
736
		} else if (J2EEProjectUtilities.isJCAProject(project)) {
737
			type = J2EEVersionConstants.CONNECTOR_TYPE;
738
			ddURI = J2EEConstants.RAR_DD_URI;
739
		} else if (J2EEProjectUtilities.isDynamicWebProject(project)) {
740
			type = J2EEVersionConstants.WEB_TYPE;
741
			ddURI = J2EEConstants.WEBAPP_DD_URI;
742
		} 
743
744
		if(type != J2EEVersionConstants.UNKNOWN){
745
			IVirtualComponent comp = ComponentCore.createComponent(project);
746
			if (comp != null) {
747
				IVirtualFile vFile = comp.getRootFolder().getFile(new Path(ddURI));
748
				if(vFile.exists()){
749
					InputStream in= null;
750
					try{
751
						in = vFile.getUnderlyingFile().getContents();
752
						JavaEEQuickPeek quickPeek = new JavaEEQuickPeek(in);
753
						int vers = (quickPeek.getVersion() == J2EEVersionConstants.UNKNOWN) ? getJEEVersion(project) : quickPeek.getVersion();
754
						return J2EEVersionUtil.convertVersionIntToString(vers);
755
					} catch (CoreException e) {
756
						Logger.getLogger().logError(e);
757
					} finally {
758
						if(in != null){
759
							try {
760
								in.close();
761
							} catch (IOException e) {
762
								Logger.getLogger().logError(e);
763
							}
764
						}
765
					}
766
					
767
				}
768
			}
769
		}
770
		
771
		return null;
772
	}
773
774
775
	private static int getJEEVersion(IProject project) {
776
		if (isEARProject(project) || isApplicationClientProject(project))
777
			return J2EEVersionConstants.VERSION_5_0;
778
		if (isEJBProject(project))
779
			return J2EEVersionConstants.VERSION_3_0;
780
		if (isDynamicWebProject(project))
781
			return J2EEVersionConstants.VERSION_2_5;
782
		return J2EEVersionConstants.UNKNOWN;
783
			
784
	}
717
785
718
	public static IRuntime getServerRuntime(IProject project) throws CoreException {
786
	public static IRuntime getServerRuntime(IProject project) throws CoreException {
719
		if (project == null)
787
		if (project == null)
Lines 727-732 Link Here
727
		return FacetUtil.getRuntime(runtime);
795
		return FacetUtil.getRuntime(runtime);
728
	}
796
	}
729
797
798
	/**
799
	 * Returns the J2EE Module version based on the project Facet installed
800
	 * @param project
801
	 * @return version String
802
	 */
730
	public static String getJ2EEProjectVersion(IProject project) {
803
	public static String getJ2EEProjectVersion(IProject project) {
731
		String type = getJ2EEProjectType(project);
804
		String type = getJ2EEProjectType(project);
732
		IFacetedProject facetedProject = null;
805
		IFacetedProject facetedProject = null;
(-)property_files/eararchiveops.properties (+1 lines)
Lines 33-35 Link Here
33
_jar_UI_=.jar
33
_jar_UI_=.jar
34
Updating_manifest_Class_Path__attributes_UI_=Updating manifest Class-Path: attributes
34
Updating_manifest_Class_Path__attributes_UI_=Updating manifest Class-Path: attributes
35
_preDeploy_ERROR_=IWAE0002E {0}.preDeploy
35
_preDeploy_ERROR_=IWAE0002E {0}.preDeploy
36
MISSING_CLIENT_JAR=EJB Client Jar \"{0}\" for EJB Jar \"{1}\" missing from EAR \"{2}\".
(-)ejbcreation/org/eclipse/jst/j2ee/ejb/componentcore/util/EJBArtifactEdit.java (-1 / +2 lines)
Lines 369-375 Link Here
369
			aResource.setID(ejbJar, J2EEConstants.EJBJAR_ID);
369
			aResource.setID(ejbJar, J2EEConstants.EJBJAR_ID);
370
			// TODO add more mandatory elements
370
			// TODO add more mandatory elements
371
			try {
371
			try {
372
				aResource.saveIfNecessary();
372
				if (aResource.isModified())
373
					aResource.saveIfNecessary();
373
			} catch (Exception e) {
374
			} catch (Exception e) {
374
				// TODO Auto-generated catch block
375
				// TODO Auto-generated catch block
375
				e.printStackTrace();
376
				e.printStackTrace();
(-)j2ee-verifiers/org/eclipse/wtp/j2ee/headless/tests/j2ee/verifiers/JEEImportDataModelVerifier.java (-20 / +42 lines)
Lines 8-16 Link Here
8
8
9
import java.util.ArrayList;
9
import java.util.ArrayList;
10
import java.util.Collection;
10
import java.util.Collection;
11
import java.util.HashMap;
12
import java.util.List;
11
import java.util.List;
13
import java.util.Map;
12
import java.util.StringTokenizer;
14
13
15
import junit.framework.Assert;
14
import junit.framework.Assert;
16
15
Lines 113-119 Link Here
113
					AssertWarn.warnEquals("Archive type did not match imported project type", getExportType(), type);
112
					AssertWarn.warnEquals("Archive type did not match imported project type", getExportType(), type);
114
				}
113
				}
115
		
114
		
116
				String sProjVersion = J2EEProjectUtilities.getJ2EEProjectVersion(project);
115
				String sProjVersion = J2EEProjectUtilities.getJ2EEDDProjectVersion(project);
117
				int iProjVersion = J2EEVersionUtil.convertVersionStringToInt(sProjVersion);
116
				int iProjVersion = J2EEVersionUtil.convertVersionStringToInt(sProjVersion);
118
				int iVersionConstant = archiveQuickPeek.getVersion();
117
				int iVersionConstant = archiveQuickPeek.getVersion();
119
				if(iProjVersion != iVersionConstant){
118
				if(iProjVersion != iVersionConstant){
Lines 127-132 Link Here
127
		Assert.assertTrue("A project with name, " + project.getName() + ", should have been created by import", project.exists());
126
		Assert.assertTrue("A project with name, " + project.getName() + ", should have been created by import", project.exists());
128
	}
127
	}
129
128
129
	
130
	protected boolean isClassWithoutSource(IArchive archive, IArchiveResource aFile) {
131
		String javaUri = classUriToJavaUri(aFile.getPath().toString());
132
		if (javaUri == null)
133
			return false;
134
		return !archive.containsArchiveResource(new Path(javaUri));
135
	}
136
137
	protected final String DOT_CLASS = ".class"; //$NON-NLS-1$
138
139
	protected final String DOT_JAVA = ".java"; //$NON-NLS-1$
140
	
141
	public String classUriToJavaUri(String classUri) {
142
		if (classUri == null || !classUri.endsWith(DOT_CLASS))
143
			return null;
144
145
		String truncated = truncateIgnoreCase(classUri, DOT_CLASS);
146
		StringTokenizer tok = new StringTokenizer(truncated, "$"); //$NON-NLS-1$
147
		return tok.nextToken().concat(DOT_JAVA);
148
	}
149
	
150
	/**
151
	 * Return a substring of the first parameter, up to the last index of the
152
	 * second
153
	 */
154
	public static String truncateIgnoreCase(String aString, String trailingSubString) {
155
		int index = aString.toLowerCase().lastIndexOf(trailingSubString.toLowerCase());
156
		if (index != -1)
157
			return aString.substring(0, index);
158
		return aString;
159
	}
130
	private void verifyAllFilesImported(IArchive archive) throws Exception {
160
	private void verifyAllFilesImported(IArchive archive) throws Exception {
131
		List<IArchiveResource> resources = archive.getArchiveResources();
161
		List<IArchiveResource> resources = archive.getArchiveResources();
132
		IPath resourcePath = null;
162
		IPath resourcePath = null;
Lines 137-151 Link Here
137
		IFolder rootFolder = (IFolder)rootVirtFolder.getUnderlyingFolder();
167
		IFolder rootFolder = (IFolder)rootVirtFolder.getUnderlyingFolder();
138
		Assert.assertTrue("The root folder " + rootFolder.getName() + " should exist in the project" , rootFolder.exists());
168
		Assert.assertTrue("The root folder " + rootFolder.getName() + " should exist in the project" , rootFolder.exists());
139
		
169
		
140
		//when the foreach loops is done the classesMap will contain only thouse classes that were imported,
170
		// when the for loops is done the classes will contain only those classes that were imported,
141
		// the sourceResources list will contain a list of all of the java source resources,
171
		// the sourceResources list will contain a list of all of the java source resources,
142
		// the otherResources list will contain all other resources that arnt nested archives,
172
		// the otherResources list will contain all other resources that are not nested archives,
143
		// and any nested archive in this archive will have been set as a nested archive in 'archive'
173
		// and any nested archive in this archive will have been set as a nested archive in 'archive'
144
		Map<String,IArchiveResource> classesMap = new HashMap<String,IArchiveResource>();
174
		List<IArchiveResource> classes = new ArrayList<IArchiveResource>();
145
		List<IArchiveResource> sourceResources = new ArrayList<IArchiveResource>();
175
		List<IArchiveResource> sourceResources = new ArrayList<IArchiveResource>();
146
		List<IArchiveResource> otherResources = new ArrayList<IArchiveResource>();
176
		List<IArchiveResource> otherResources = new ArrayList<IArchiveResource>();
147
		
177
		
148
		String fileName = null;
149
		String extension = null;
178
		String extension = null;
150
		for(IArchiveResource resource : resources) {
179
		for(IArchiveResource resource : resources) {
151
			resourcePath = resource.getPath();
180
			resourcePath = resource.getPath();
Lines 154-171 Link Here
154
				case IArchiveResource.FILE_TYPE :
183
				case IArchiveResource.FILE_TYPE :
155
					extension = resourcePath.getFileExtension();
184
					extension = resourcePath.getFileExtension();
156
					
185
					
157
					if(extension.equals(CLASS_EXTENSION) || extension.equals(JAVA_EXTENSION)) {
186
					if(extension.equals(CLASS_EXTENSION)){
158
						fileName = resourcePath.removeFileExtension().lastSegment();
187
						if(isClassWithoutSource(archive, resource)){
159
						if(classesMap.containsKey(fileName)) {
188
							classes.add(resource);
160
							if(extension.equals(CLASS_EXTENSION)) {
161
								sourceResources.add(classesMap.remove(fileName));
162
							} else if(extension.equals(JAVA_EXTENSION)) {
163
								sourceResources.add(resource);
164
								classesMap.remove(fileName);
165
							}
166
						} else {
167
							classesMap.put(fileName, resource);
168
						}
189
						}
190
					} else if(extension.equals(JAVA_EXTENSION)){
191
						sourceResources.add(resource);
169
					} else if(extension.equals(JAR_EXTENSION) || extension.equals(RAR_EXTENSION) || extension.equals(WAR_EXTENSION)) {
192
					} else if(extension.equals(JAR_EXTENSION) || extension.equals(RAR_EXTENSION) || extension.equals(WAR_EXTENSION)) {
170
						archive.getNestedArchive(resource);
193
						archive.getNestedArchive(resource);
171
					} else {
194
					} else {
Lines 182-191 Link Here
182
			}
205
			}
183
		}
206
		}
184
		
207
		
185
		Collection<IArchiveResource> importedClassesResources = classesMap.values();
186
		List<IArchive> nestedArchives = archive.getNestedArchives();
208
		List<IArchive> nestedArchives = archive.getNestedArchives();
187
		
209
		
188
		verifyImportedResources(sourceResources, importedClassesResources, otherResources, nestedArchives, rootFolder, importedClassesFolder);
210
		verifyImportedResources(sourceResources, classes, otherResources, nestedArchives, rootFolder, importedClassesFolder);
189
	}
211
	}
190
	
212
	
191
	protected abstract void verifyImportedResources(Collection<IArchiveResource> sourceResources, Collection<IArchiveResource> importedClassesResources, Collection<IArchiveResource> otherResources, Collection<IArchive> nestedArchives, IFolder rootFolder, IFolder importedClassesFolder) throws Exception;
213
	protected abstract void verifyImportedResources(Collection<IArchiveResource> sourceResources, Collection<IArchiveResource> importedClassesResources, Collection<IArchiveResource> otherResources, Collection<IArchive> nestedArchives, IFolder rootFolder, IFolder importedClassesFolder) throws Exception;
(-)j2ee-verifiers/org/eclipse/wtp/j2ee/headless/tests/j2ee/verifiers/JEEExportDataModelVerifier.java (-1 / +1 lines)
Lines 121-127 Link Here
121
				int type = archiveQuickPeek.getType();
121
				int type = archiveQuickPeek.getType();
122
				AssertWarn.warnEquals("Archive type did not match exported type", getExportType(), type);
122
				AssertWarn.warnEquals("Archive type did not match exported type", getExportType(), type);
123
				int iVersionConstant = archiveQuickPeek.getVersion();
123
				int iVersionConstant = archiveQuickPeek.getVersion();
124
				String sProjVersion = J2EEProjectUtilities.getJ2EEProjectVersion(exportedProj);
124
				String sProjVersion = J2EEProjectUtilities.getJ2EEDDProjectVersion(exportedProj);
125
				int iProjVersion = J2EEVersionUtil.convertVersionStringToInt(sProjVersion);
125
				int iProjVersion = J2EEVersionUtil.convertVersionStringToInt(sProjVersion);
126
				AssertWarn.warnEquals("Archive version did not match exported project version", iProjVersion, iVersionConstant);
126
				AssertWarn.warnEquals("Archive version did not match exported project version", iProjVersion, iVersionConstant);
127
			} finally {
127
			} finally {
(-)j2ee-verifiers/org/eclipse/wtp/j2ee/headless/tests/web/verifiers/WebImportDataModelVerifier.java (-1 / +51 lines)
Lines 6-11 Link Here
6
 */
6
 */
7
package org.eclipse.wtp.j2ee.headless.tests.web.verifiers;
7
package org.eclipse.wtp.j2ee.headless.tests.web.verifiers;
8
8
9
import java.io.FileNotFoundException;
9
import java.util.Collection;
10
import java.util.Collection;
10
11
11
import junit.framework.Assert;
12
import junit.framework.Assert;
Lines 13-18 Link Here
13
import org.eclipse.core.resources.IFile;
14
import org.eclipse.core.resources.IFile;
14
import org.eclipse.core.resources.IFolder;
15
import org.eclipse.core.resources.IFolder;
15
import org.eclipse.core.runtime.IPath;
16
import org.eclipse.core.runtime.IPath;
17
import org.eclipse.core.runtime.Path;
18
import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveConstants;
19
import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil;
16
import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
20
import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
17
import org.eclipse.jst.jee.archive.IArchive;
21
import org.eclipse.jst.jee.archive.IArchive;
18
import org.eclipse.jst.jee.archive.IArchiveResource;
22
import org.eclipse.jst.jee.archive.IArchiveResource;
Lines 60-66 Link Here
60
		for(IArchiveResource importedClassResource : importedClassesResources) {
64
		for(IArchiveResource importedClassResource : importedClassesResources) {
61
			resourcePath = importedClassResource.getPath().removeFirstSegments(2);
65
			resourcePath = importedClassResource.getPath().removeFirstSegments(2);
62
			resourceFile = importedClassesFolder.getFile(resourcePath);
66
			resourceFile = importedClassesFolder.getFile(resourcePath);
63
			Assert.assertTrue("The imported class " + resourcePath + " should exist in the project", resourceFile.exists());
67
			if(!resourceFile.exists()){
68
				Assert.fail("The imported class " + resourcePath + " should exist in the project");
69
			}
64
		}
70
		}
65
		
71
		
66
		for(IArchiveResource otherResource : otherResources) {
72
		for(IArchiveResource otherResource : otherResources) {
Lines 73-76 Link Here
73
			
79
			
74
		}
80
		}
75
	}
81
	}
82
	
83
	protected boolean isClassWithoutSource(IArchive archive, IArchiveResource aFile) {
84
		String javaUri = ArchiveUtil.classUriToJavaUri(aFile.getPath().toString());
85
		if (javaUri == null)
86
			return true;
87
		IPath javaPath = new Path(javaUri);
88
		if (archive.containsArchiveResource(javaPath)) {
89
			return false;
90
		}
91
		// see if it is a JSP
92
		String jspUri = javaUri.substring(0, javaUri.indexOf(ArchiveUtil.DOT_JAVA));
93
		int lastSlash = jspUri.lastIndexOf('/');
94
		int _index = lastSlash == -1 ? ArchiveConstants.WEBAPP_CLASSES_URI.length() : lastSlash + 1;
95
		if (jspUri.charAt(_index) == '_') {
96
			jspUri = jspUri.substring(ArchiveConstants.WEBAPP_CLASSES_URI.length(), _index) + jspUri.substring(_index + 1) + ArchiveUtil.DOT_JSP;
97
			IPath jspPath = new Path(jspUri);
98
			if (archive.containsArchiveResource(jspPath)) {
99
				return false;
100
			}
101
		}
102
103
		//This is to handle archives created by an earlier version
104
		//The format was to include the source files in a directory called source in WEB-INF
105
		//Example: class  is in WEB-INF/classes/test/Foo.class
106
		//         source is in WEB-INF/source/test/Foo.java
107
		if(javaPath.segmentCount() > 2 && javaPath.segment(0).equals("WEB-INF") && javaPath.segment(1).equals("classes")){
108
			String alternateJavaUri = javaUri.replaceFirst("classes", "source");
109
			IPath alternateJavaPath = new Path(alternateJavaUri);
110
			if (archive.containsArchiveResource(alternateJavaPath)){
111
				IArchiveResource sourceFile;
112
				try {
113
					sourceFile = archive.getArchiveResource(alternateJavaPath);
114
					if(sourceFile != null){
115
						return false;
116
					}
117
				} catch (FileNotFoundException e) {
118
				}
119
				
120
			}
121
			
122
		}
123
		
124
		return true;
125
	}
76
}
126
}
(-)j2ee-verifiers/org/eclipse/wtp/j2ee/headless/tets/appclient/verifiers/AppClientImportDataModelVerifier.java (-1 / +3 lines)
Lines 52-58 Link Here
52
		for(IArchiveResource sourceResource : sourceResources) {
52
		for(IArchiveResource sourceResource : sourceResources) {
53
			resourcePath = sourceResource.getPath();
53
			resourcePath = sourceResource.getPath();
54
			resourceFile = rootFolder.getFile(resourcePath);
54
			resourceFile = rootFolder.getFile(resourcePath);
55
			Assert.assertTrue("The file " + resourcePath + " should exist in the project", resourceFile.exists());
55
			if(!resourceFile.exists()){
56
				Assert.fail("The file " + resourcePath + " should exist in the project");
57
			}
56
		}
58
		}
57
		
59
		
58
		for(IArchiveResource importedClassResource : importedClassesResources) {
60
		for(IArchiveResource importedClassResource : importedClassesResources) {
(-)j2ee_ui/org/eclipse/jst/j2ee/internal/AvailableJ2EEComponentsForEARContentProvider.java (-6 / +8 lines)
Lines 49-54 Link Here
49
public class AvailableJ2EEComponentsForEARContentProvider implements IStructuredContentProvider, ITableLabelProvider {
49
public class AvailableJ2EEComponentsForEARContentProvider implements IStructuredContentProvider, ITableLabelProvider {
50
	private int j2eeVersion;
50
	private int j2eeVersion;
51
	private IVirtualComponent earComponent;
51
	private IVirtualComponent earComponent;
52
	private boolean isEE5 = false;
52
53
53
	public AvailableJ2EEComponentsForEARContentProvider(IVirtualComponent aEarComponent, int j2eeVersion) {
54
	public AvailableJ2EEComponentsForEARContentProvider(IVirtualComponent aEarComponent, int j2eeVersion) {
54
		super();
55
		super();
Lines 62-67 Link Here
62
	 * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
63
	 * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
63
	 */
64
	 */
64
	public Object[] getElements(Object inputElement) {
65
	public Object[] getElements(Object inputElement) {
66
		if (null != earComponent){
67
			isEE5 = J2EEProjectUtilities.isJEEProject(earComponent.getProject());
68
		}
65
		Object[] empty = new Object[0];
69
		Object[] empty = new Object[0];
66
		if (!(inputElement instanceof IWorkspaceRoot))
70
		if (!(inputElement instanceof IWorkspaceRoot))
67
			return empty;
71
			return empty;
Lines 81-103 Link Here
81
						J2EEProjectUtilities.isJCAProject(project) ||
85
						J2EEProjectUtilities.isJCAProject(project) ||
82
						J2EEProjectUtilities.isUtilityProject(project) ){
86
						J2EEProjectUtilities.isUtilityProject(project) ){
83
					int compJ2EEVersion = J2EEVersionUtil.convertVersionStringToInt(component);
87
					int compJ2EEVersion = J2EEVersionUtil.convertVersionStringToInt(component);
84
					if( compJ2EEVersion <= j2eeVersion)
88
					if( compJ2EEVersion <= j2eeVersion){
85
						//validCompList.add(component.getProject());
89
						validCompList.add(component);
90
					} else if(isEE5){
86
						validCompList.add(component);
91
						validCompList.add(component);
92
					}
87
				}else if(null != earComponent && J2EEProjectUtilities.isEARProject(project)){
93
				}else if(null != earComponent && J2EEProjectUtilities.isEARProject(project)){
88
					//find the ArchiveComponent
94
					//find the ArchiveComponent
89
					if( component.equals( earComponent )){
95
					if( component.equals( earComponent )){
90
						IVirtualReference[] newrefs = component.getReferences();
96
						IVirtualReference[] newrefs = component.getReferences();
91
						for( int k=0; k< newrefs.length; k++ ){
97
						for( int k=0; k< newrefs.length; k++ ){
92
							IVirtualReference tmpref = newrefs[k];
98
							IVirtualReference tmpref = newrefs[k];
93
							//IVirtualComponent enclosingcomp = tmpref.getEnclosingComponent();
94
							//boolean isBinary = enclosingcomp.isBinary();
95
							IVirtualComponent referencedcomp = tmpref.getReferencedComponent();		
99
							IVirtualComponent referencedcomp = tmpref.getReferencedComponent();		
96
							boolean isBinary = referencedcomp.isBinary();
100
							boolean isBinary = referencedcomp.isBinary();
97
							if( isBinary ){
101
							if( isBinary ){
98
								validCompList.add(referencedcomp);
102
								validCompList.add(referencedcomp);
99
								//validCompList.add(referencedcomp.getProject());
100
								//IPath path = ComponentUtilities.getResolvedPathForArchiveComponent(name);
101
							} else {
103
							} else {
102
								addClasspathComponentDependencies(validCompList, pathToComp, referencedcomp);
104
								addClasspathComponentDependencies(validCompList, pathToComp, referencedcomp);
103
							}
105
							}
(-)rarproject/org/eclipse/jst/j2ee/internal/jca/operations/ConnectorComponentImportOperation.java (-9 / +5 lines)
Lines 11-17 Link Here
11
package org.eclipse.jst.j2ee.internal.jca.operations;
11
package org.eclipse.jst.j2ee.internal.jca.operations;
12
12
13
import java.util.ArrayList;
13
import java.util.ArrayList;
14
import java.util.Iterator;
15
import java.util.List;
14
import java.util.List;
16
15
17
import org.eclipse.core.commands.ExecutionException;
16
import org.eclipse.core.commands.ExecutionException;
Lines 23-34 Link Here
23
import org.eclipse.jdt.core.JavaCore;
22
import org.eclipse.jdt.core.JavaCore;
24
import org.eclipse.jdt.core.JavaModelException;
23
import org.eclipse.jdt.core.JavaModelException;
25
import org.eclipse.jem.util.logger.proxy.Logger;
24
import org.eclipse.jem.util.logger.proxy.Logger;
26
import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
27
import org.eclipse.jst.j2ee.commonarchivecore.internal.ModuleFile;
28
import org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.SaveStrategy;
25
import org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.SaveStrategy;
29
import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentImportDataModelProperties;
26
import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentImportDataModelProperties;
30
import org.eclipse.jst.j2ee.internal.archive.operations.ConnectorComponentSaveStrategyImpl;
27
import org.eclipse.jst.j2ee.internal.archive.operations.ConnectorComponentSaveStrategyImpl;
31
import org.eclipse.jst.j2ee.internal.archive.operations.J2EEArtifactImportOperation;
28
import org.eclipse.jst.j2ee.internal.archive.operations.J2EEArtifactImportOperation;
29
import org.eclipse.jst.jee.archive.IArchive;
32
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
30
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
33
import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
31
import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
34
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
32
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
Lines 52-65 Link Here
52
	protected void addAssociateArchivesToClassPath() {
50
	protected void addAssociateArchivesToClassPath() {
53
		List extraEntries = new ArrayList();
51
		List extraEntries = new ArrayList();
54
		
52
		
55
		List archiveList = ((ModuleFile)archiveWrapper.getUnderLyingArchive()).getArchiveFiles();
53
		List <IArchive> nestedArchives = ((IArchive)archiveWrapper.getUnderLyingArchive()).getNestedArchives();
56
		Iterator iterator = archiveList.iterator();
57
		IVirtualFile vFile = null;
54
		IVirtualFile vFile = null;
58
		IFile file = null;
55
		IFile file = null;
59
		while (iterator.hasNext()) {
56
		for(IArchive nestedArchive : nestedArchives){
60
			Archive anArchive = (Archive) iterator.next();
57
			if(nestedArchive.getPath().lastSegment().endsWith(JAR_EXTENSION)){
61
			if (anArchive.getName().endsWith(JAR_EXTENSION)) {
58
				vFile = virtualComponent.getRootFolder().getFile(nestedArchive.getPath());
62
				vFile = virtualComponent.getRootFolder().getFile(anArchive.getURI());
63
				if (vFile.exists()) {
59
				if (vFile.exists()) {
64
					file = vFile.getUnderlyingFile();
60
					file = vFile.getUnderlyingFile();
65
					extraEntries.add(JavaCore.newLibraryEntry(file.getFullPath(), file.getFullPath(), null, true));
61
					extraEntries.add(JavaCore.newLibraryEntry(file.getFullPath(), file.getFullPath(), null, true));

Return to bug 206086