Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 367860

Summary: Avoid IllegalArgumentException in Validation filters
Product: [WebTools] WTP Common Tools Reporter: Rosendo Martinez <rosendo>
Component: wst.validationAssignee: Rosendo Martinez <rosendo>
Status: RESOLVED FIXED QA Contact: Chuck Bridgham <cbridgha>
Severity: normal    
Priority: P3 CC: ccc, shr31223
Version: 3.3.1Flags: cbridgha: review+
Target Milestone: 3.3.2   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed R3_3_maintenance patch shr31223: iplog+

Description Rosendo Martinez CLA 2012-01-04 10:30:19 EST
Build Identifier: 

There have been IllegalArgumentException exceptions when trying to set validation filter rules, Facet and Target Runtime.

Adding try/catch to avoid them.

Reproducible: Always
Comment 1 Rosendo Martinez CLA 2012-01-04 13:25:40 EST
Created attachment 209028 [details]
Proposed R3_3_maintenance patch
Comment 2 Chuck Bridgham CLA 2012-01-05 17:07:31 EST
Rosendo - can you provide more details?  I don't like to ignore exceptions unless we have a very clear reason.
Comment 3 Rosendo Martinez CLA 2012-01-06 10:51:07 EST
Sure, here they are:

1. Time ago there was a requirement to display not only the facet, project nature  and content type ids, but also the names of those filter types in the Validation Filters dialog , see the Bug 302914. 

The main idea was to display the filter rules as following:

Name - id

2. To get the name, the following APIs were used:

ProjectFacetsManager.getProjectFacet(id)
ResourcesPlugin.getWorkspace().getNatureDescriptor(String)
RuntimeManager.getRuntime(id)

Some of those meths throw an IllegalArgumentException exception when the id does not exist in the current workspace facets, so the name is not returned.

3. To avoid that exception, I am adding try/catch pairs. When the exception is thrown, the catch does not need to do something in particular since only the id will be displayed, with no name before it.

Please, let me know any comment/question.
Comment 4 Chuck Bridgham CLA 2012-01-11 09:16:36 EST
ok I approve...  if the runtime or facet is not recognized...  we will handle nicely in this case.
Comment 5 Roberto Sanchez Herrera CLA 2012-01-11 11:50:26 EST
Code committed to R3_3_maintenance and HEAD for WTP 3.3.2 and 3.4. Resolving defect