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 297882 | Differences between
and this patch

Collapse All | Expand All

(-)j2eecreation/org/eclipse/jst/j2ee/project/SingleRootUtil.java (-19 / +22 lines)
Lines 176-181 Link Here
176
				return getStatus();
176
				return getStatus();
177
			}
177
			}
178
			
178
			
179
			if (resourceMaps.size() == 1) {
180
				ComponentResource mapping = (ComponentResource)resourceMaps.get(0); 
181
				if (isRootMapping(mapping)) {
182
					IResource sourceResource = getProject().findMember(mapping.getSourcePath());
183
					if (sourceResource instanceof IContainer && !isSourceContainer((IContainer) sourceResource)) {
184
						reportStatus(ISingleRootStatus.SINGLE_ROOT_CONTAINER_FOUND, (IContainer) sourceResource);
185
						return getStatus();
186
					}
187
				}
188
			}
189
			
179
			if (JavaEEProjectUtilities.isDynamicWebProject(getProject())) {
190
			if (JavaEEProjectUtilities.isDynamicWebProject(getProject())) {
180
				//validate web projects for single root
191
				//validate web projects for single root
181
				validateWebProject(resourceMaps);
192
				validateWebProject(resourceMaps);
Lines 373-381 Link Here
373
		for (int i=0; i < resourceMaps.size(); i++) {
384
		for (int i=0; i < resourceMaps.size(); i++) {
374
			ComponentResource resourceMap = (ComponentResource) resourceMaps.get(i);
385
			ComponentResource resourceMap = (ComponentResource) resourceMaps.get(i);
375
			// Verify it maps to "/" for the content root
386
			// Verify it maps to "/" for the content root
376
			IPath runtimePath = resourceMap.getRuntimePath();
387
			if (!isRootMapping(resourceMap)) {
377
			if (!runtimePath.equals(Path.ROOT)) {
388
				reportStatus(ISingleRootStatus.RUNTIME_PATH_NOT_ROOT, resourceMap.getRuntimePath());
378
				reportStatus(ISingleRootStatus.RUNTIME_PATH_NOT_ROOT, runtimePath);
379
				if (VALIDATE_FLAG == CANCEL) return false;
389
				if (VALIDATE_FLAG == CANCEL) return false;
380
			}
390
			}
381
			
391
			
Lines 395-400 Link Here
395
		return true;
405
		return true;
396
	}
406
	}
397
	
407
	
408
	private boolean isRootMapping(ComponentResource map) {
409
		// Verify it maps to "/" for the content root
410
		if (map.getRuntimePath().equals(Path.ROOT))
411
			return true;
412
		return false;
413
	}
414
	
398
	/**
415
	/**
399
	 * Ensure the default web setup is correct with one resource map and any number of java 
416
	 * Ensure the default web setup is correct with one resource map and any number of java 
400
	 * resource maps to WEB-INF/classes
417
	 * resource maps to WEB-INF/classes
Lines 404-416 Link Here
404
	 */
421
	 */
405
	private boolean hasDefaultWebResourceMappings(List resourceMaps) {
422
	private boolean hasDefaultWebResourceMappings(List resourceMaps) {
406
		int rootValidMaps = 0;
423
		int rootValidMaps = 0;
407
		int javaValidRoots = 0;
408
		
409
		// If there aren't at least 2 maps, return false
410
		if (VALIDATE_FLAG == INCLUDE_FIRST_ERROR && resourceMaps.size() < 2) {
411
			reportStatus(ISingleRootStatus.ATLEAST_1_RESOURCE_MAP_MISSING);
412
			return false;
413
		}
414
		
424
		
415
		IPath webInfClasses = new Path(J2EEConstants.WEB_INF_CLASSES).makeAbsolute();
425
		IPath webInfClasses = new Path(J2EEConstants.WEB_INF_CLASSES).makeAbsolute();
416
		for (int i = 0; i < resourceMaps.size(); i++) {
426
		for (int i = 0; i < resourceMaps.size(); i++) {
Lines 420-435 Link Here
420
			IResource sourceResource = getProject().findMember(sourcePath);
430
			IResource sourceResource = getProject().findMember(sourcePath);
421
			
431
			
422
			// Verify if the map is for the content root
432
			// Verify if the map is for the content root
423
			if (runtimePath.equals(Path.ROOT)) {
433
			if (isRootMapping(resourceMap)) {
424
				rootValidMaps++;
434
				rootValidMaps++;
425
			} 
435
			} 
426
			// Verify if the map is for a java src folder and is mapped to "WEB-INF/classes"
436
			// Verify if the map is for a java src folder and is mapped to "WEB-INF/classes"
427
			else if (runtimePath.equals(webInfClasses)) {
437
			else if (runtimePath.equals(webInfClasses)) {
428
				if (sourceResource != null && sourceResource.exists()) {
438
				if (sourceResource != null && sourceResource.exists()) {
429
					if (sourceResource instanceof IContainer && isSourceContainer((IContainer) sourceResource)) {
439
					if (sourceResource instanceof IContainer && !isSourceContainer((IContainer) sourceResource)) {
430
						javaValidRoots++;
431
					}
432
					else {
433
						reportStatus(ISingleRootStatus.SOURCE_NOT_JAVA_CONTAINER, sourcePath);
440
						reportStatus(ISingleRootStatus.SOURCE_NOT_JAVA_CONTAINER, sourcePath);
434
					}
441
					}
435
				}
442
				}
Lines 450-460 Link Here
450
			else if (rootValidMaps > 1) {
457
			else if (rootValidMaps > 1) {
451
				reportStatus(ISingleRootStatus.ONLY_1_CONTENT_ROOT_ALLOWED);
458
				reportStatus(ISingleRootStatus.ONLY_1_CONTENT_ROOT_ALLOWED);
452
			}
459
			}
453
			if (VALIDATE_FLAG == CANCEL) return false;
454
		}
460
		}
455
		if (javaValidRoots < 1) {
456
			reportStatus(ISingleRootStatus.ATLEAST_1_JAVA_SOURCE_REQUIRED);
457
		}		
458
		return VALIDATE_FLAG == CANCEL ? false : true;
461
		return VALIDATE_FLAG == CANCEL ? false : true;
459
	}
462
	}
460
	
463
	
(-)j2eecreation/org/eclipse/jst/j2ee/project/ISingleRootStatus.java (-13 / +9 lines)
Lines 37-62 Link Here
37
37
38
	public static final int JAVA_OUTPUT_NOT_WEBINF_CLASSES = 72;
38
	public static final int JAVA_OUTPUT_NOT_WEBINF_CLASSES = 72;
39
39
40
	public static final int ATLEAST_1_RESOURCE_MAP_MISSING = 73;
40
	public static final int NO_RESOURCE_MAPS_FOUND = 73;
41
41
42
	public static final int NO_RESOURCE_MAPS_FOUND = 74;
42
	public static final int ONE_CONTENT_ROOT_REQUIRED = 74;
43
43
44
	public static final int ONE_CONTENT_ROOT_REQUIRED = 75;
44
	public static final int RUNTIME_PATH_NOT_ROOT = 75;
45
45
46
	public static final int ATLEAST_1_JAVA_SOURCE_REQUIRED = 76;
46
	public static final int SOURCE_NOT_JAVA_CONTAINER = 76;
47
47
48
	public static final int RUNTIME_PATH_NOT_ROOT = 77;
48
	public static final int RUNTIME_PATH_NOT_ROOT_OR_WEBINF_CLASSES = 77;
49
49
50
	public static final int SOURCE_NOT_JAVA_CONTAINER = 78;
50
	public static final int ONLY_1_CONTENT_ROOT_ALLOWED = 78;
51
52
	public static final int RUNTIME_PATH_NOT_ROOT_OR_WEBINF_CLASSES = 79;
53
54
	public static final int ONLY_1_CONTENT_ROOT_ALLOWED = 80;
55
	
51
	
56
	public static final int EXPLICITLY_DISABLED = 81;
52
	public static final int EXPLICITLY_DISABLED = 79;
57
58
	public static final int CONSUMABLE_REFERENCES_FOUND = 82;
59
53
54
	public static final int CONSUMABLE_REFERENCES_FOUND = 80;
55
	
60
	
56
	
61
	/**
57
	/**
62
	 * Returns the path with which the status is associated.
58
	 * Returns the path with which the status is associated.

Return to bug 297882