This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 42686

Summary: Infrastructure to permit validation by Schema of project.xml & private.xml
Product: projects Reporter: Jesse Glick <jglick>
Component: Ant ProjectAssignee: Jesse Glick <jglick>
Status: RESOLVED FIXED    
Severity: blocker CC: apireviews, dkonecny, tmysik
Priority: P3 Keywords: API, API_REVIEW_FAST
Version: 4.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:
Bug Depends on: 139755, 139756, 172393, 139754, 140640, 143966, 195029    
Bug Blocks: 41535, 42682, 47288    
Attachments: Patch in progress

Description Jesse Glick 2004-05-01 17:27:50 UTC
When a module is loaded, it should be easy to
validate its XML metadata against XML Schemas.

Maybe plugged into a more general API that lets a
project mark itself as erroneous and provide a
correction action.

Especially valuable for freeform project type
which would have a particularly complex project.xml.
Comment 1 Jesse Glick 2004-06-15 13:16:03 UTC
Perhaps for E.
Comment 2 Jesse Glick 2004-09-14 18:19:44 UTC
*** Issue 48987 has been marked as a duplicate of this issue. ***
Comment 3 Jesse Glick 2005-03-07 16:55:25 UTC
Freeform project.xml automatic validation already uses a registered
local schema location (see freeform SPI). For other project types,
there is not yet any registration mechanism, so only web locations are
permitted (i.e. you need to have a network connection and proper
firewall config).
Comment 4 Jesse Glick 2005-06-03 00:24:14 UTC
*** Issue 59560 has been marked as a duplicate of this issue. ***
Comment 5 Jesse Glick 2005-06-09 21:32:11 UTC
*** Issue 59807 has been marked as a duplicate of this issue. ***
Comment 6 Jesse Glick 2005-06-09 21:36:54 UTC
*** Issue 59560 has been marked as a duplicate of this issue. ***
Comment 7 Jesse Glick 2007-02-20 19:52:09 UTC
*** Issue 96068 has been marked as a duplicate of this issue. ***
Comment 8 Jesse Glick 2007-05-23 18:23:34 UTC
*** Issue 104516 has been marked as a duplicate of this issue. ***
Comment 9 Jesse Glick 2008-07-03 20:15:43 UTC
I am working on this.
Comment 10 Jesse Glick 2008-07-03 20:35:06 UTC
*** Issue 47288 has been marked as a duplicate of this issue. ***
Comment 11 Jesse Glick 2008-07-03 21:00:12 UTC
Created attachment 63910 [details]
Patch in progress
Comment 12 Jesse Glick 2008-07-03 21:04:48 UTC
Please review the attached patch. (A detailed summary of changes can be found in the header of the patch.) To be done
before committing:

1. Register schemas for other project types: web, EJB, etc.

2. Add more unit tests in project.ant for new behavior.

3. Spec version changes, apichanges.xml & arch.xml where needed.

4. Some better quality of implementation in AntProjectHelper - clearer error reporting, better error recovery.

5. Caching of schemas between calls to validate so they do not need to be parsed repeatedly.
Comment 13 David Konecny 2008-07-03 22:08:45 UTC
Looks OK to me. Considering it is just registration would you mind fixing also 4 j2ee project types? (web.project,
j2ee.ejbjarproject, j2ee.earproject and j2ee.clientproject). If not file an issue please and somebody might fix it in
next year or two.
Comment 14 Jesse Glick 2008-07-03 23:49:29 UTC
Yes, as in #1 I would register schemas for all project types, plus jaxws and any other misc stuff that registers
project-related schemas I find.
Comment 15 Jesse Glick 2008-07-11 17:47:17 UTC
Registering schemas for everything except Ruby, SOA, Scala, and Erlang project types (filed as dependencies).
Comment 16 Jesse Glick 2008-07-11 21:24:52 UTC
core-main #e040c95e86ef
Comment 17 Quality Engineering 2008-07-17 04:31:42 UTC
Integrated into 'main-golden', available in NB_Trunk_Production #324 build
Changeset: http://hg.netbeans.org/main/rev/e040c95e86ef
User: Jesse Glick <jglick@netbeans.org>
Log: Issue #42686: consistent validation of project metadata according to schema.
1. XMLUtil.validate utility method added.
2. XML catalog for project metadata now read from ProjectXMLCatalog in the system filesystem, not the web.
   Register http://www.netbeans.org/ns/foo/1 as ProjectXMLCatalog/foo/1.xsd to be found.
3. Validate project.xml/private.xml according to schemas found in ProjectXMLCatalog:
   a. When loading a project, if project.xml is invalid then make the load fail.
      (Effectively preventing older IDEs from trying to load newer IDEs' projects, if schemas changed.)
   b. Validate before saving project.xml/private.xml, to guard against buggy module code.
   c. Validate before loading project.xml/private.xml, to guard against e.g. bad user edits or VCS conflict markers.
   Note that e.g. <configuration> uses lax subelement processing, so children with no matching schemas will be skipped.
4. Remove logic to display validation errors of freeform project.xml in Output Window.
   Users can anyway use A-S-F9 to use the regular Validate action before saving.
5. ant.freeform.ProjectNature.getSchemas removed (natures need no longer implement it).
Comment 18 _ dcaoyuan 2008-07-23 21:10:49 UTC
oops, wrong typing this issue
Comment 19 Jesse Glick 2008-07-23 23:47:39 UTC
Mistakenly reopened?