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 / +24 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 != null && sourceResource.exists()) {
184
						if (sourceResource instanceof IContainer && !isSourceContainer((IContainer) sourceResource)) {
185
							reportStatus(ISingleRootStatus.SINGLE_ROOT_CONTAINER_FOUND, (IContainer) sourceResource);
186
							return getStatus();
187
						}
188
					}
189
				}
190
			}
191
			
179
			if (JavaEEProjectUtilities.isDynamicWebProject(getProject())) {
192
			if (JavaEEProjectUtilities.isDynamicWebProject(getProject())) {
180
				//validate web projects for single root
193
				//validate web projects for single root
181
				validateWebProject(resourceMaps);
194
				validateWebProject(resourceMaps);
Lines 373-381 Link Here
373
		for (int i=0; i < resourceMaps.size(); i++) {
386
		for (int i=0; i < resourceMaps.size(); i++) {
374
			ComponentResource resourceMap = (ComponentResource) resourceMaps.get(i);
387
			ComponentResource resourceMap = (ComponentResource) resourceMaps.get(i);
375
			// Verify it maps to "/" for the content root
388
			// Verify it maps to "/" for the content root
376
			IPath runtimePath = resourceMap.getRuntimePath();
389
			if (!isRootMapping(resourceMap)) {
377
			if (!runtimePath.equals(Path.ROOT)) {
390
				reportStatus(ISingleRootStatus.RUNTIME_PATH_NOT_ROOT, resourceMap.getRuntimePath());
378
				reportStatus(ISingleRootStatus.RUNTIME_PATH_NOT_ROOT, runtimePath);
379
				if (VALIDATE_FLAG == CANCEL) return false;
391
				if (VALIDATE_FLAG == CANCEL) return false;
380
			}
392
			}
381
			
393
			
Lines 395-400 Link Here
395
		return true;
407
		return true;
396
	}
408
	}
397
	
409
	
410
	private boolean isRootMapping(ComponentResource map) {
411
		// Verify it maps to "/" for the content root
412
		if (map.getRuntimePath().equals(Path.ROOT))
413
			return true;
414
		return false;
415
	}
416
	
398
	/**
417
	/**
399
	 * Ensure the default web setup is correct with one resource map and any number of java 
418
	 * Ensure the default web setup is correct with one resource map and any number of java 
400
	 * resource maps to WEB-INF/classes
419
	 * resource maps to WEB-INF/classes
Lines 404-416 Link Here
404
	 */
423
	 */
405
	private boolean hasDefaultWebResourceMappings(List resourceMaps) {
424
	private boolean hasDefaultWebResourceMappings(List resourceMaps) {
406
		int rootValidMaps = 0;
425
		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
		
426
		
415
		IPath webInfClasses = new Path(J2EEConstants.WEB_INF_CLASSES).makeAbsolute();
427
		IPath webInfClasses = new Path(J2EEConstants.WEB_INF_CLASSES).makeAbsolute();
416
		for (int i = 0; i < resourceMaps.size(); i++) {
428
		for (int i = 0; i < resourceMaps.size(); i++) {
Lines 420-435 Link Here
420
			IResource sourceResource = getProject().findMember(sourcePath);
432
			IResource sourceResource = getProject().findMember(sourcePath);
421
			
433
			
422
			// Verify if the map is for the content root
434
			// Verify if the map is for the content root
423
			if (runtimePath.equals(Path.ROOT)) {
435
			if (isRootMapping(resourceMap)) {
424
				rootValidMaps++;
436
				rootValidMaps++;
425
			} 
437
			} 
426
			// Verify if the map is for a java src folder and is mapped to "WEB-INF/classes"
438
			// Verify if the map is for a java src folder and is mapped to "WEB-INF/classes"
427
			else if (runtimePath.equals(webInfClasses)) {
439
			else if (runtimePath.equals(webInfClasses)) {
428
				if (sourceResource != null && sourceResource.exists()) {
440
				if (sourceResource != null && sourceResource.exists()) {
429
					if (sourceResource instanceof IContainer && isSourceContainer((IContainer) sourceResource)) {
441
					if (sourceResource instanceof IContainer && !isSourceContainer((IContainer) sourceResource)) {
430
						javaValidRoots++;
431
					}
432
					else {
433
						reportStatus(ISingleRootStatus.SOURCE_NOT_JAVA_CONTAINER, sourcePath);
442
						reportStatus(ISingleRootStatus.SOURCE_NOT_JAVA_CONTAINER, sourcePath);
434
					}
443
					}
435
				}
444
				}
Lines 450-460 Link Here
450
			else if (rootValidMaps > 1) {
459
			else if (rootValidMaps > 1) {
451
				reportStatus(ISingleRootStatus.ONLY_1_CONTENT_ROOT_ALLOWED);
460
				reportStatus(ISingleRootStatus.ONLY_1_CONTENT_ROOT_ALLOWED);
452
			}
461
			}
453
			if (VALIDATE_FLAG == CANCEL) return false;
454
		}
462
		}
455
		if (javaValidRoots < 1) {
456
			reportStatus(ISingleRootStatus.ATLEAST_1_JAVA_SOURCE_REQUIRED);
457
		}		
458
		return VALIDATE_FLAG == CANCEL ? false : true;
463
		return VALIDATE_FLAG == CANCEL ? false : true;
459
	}
464
	}
460
	
465
	

Return to bug 297882