Bug 316561 - The EAR project name <> can not be the same as the project name but it isn't
Summary: The EAR project name <> can not be the same as the project name but it isn't
Status: RESOLVED FIXED
Alias: None
Product: WTP Common Tools
Classification: WebTools
Component: wst.common (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P1 major (vote)
Target Milestone: 3.2.1   Edit
Assignee: Carl Anderson CLA
QA Contact: Carl Anderson CLA
URL:
Whiteboard:
Keywords:
Depends on: 294671
Blocks:
  Show dependency tree
 
Reported: 2010-06-10 19:52 EDT by Andrew Fernandez CLA
Modified: 2010-06-23 14:02 EDT (History)
4 users (show)

See Also:
ccc: review+


Attachments
Set the model property, then check for error (1.55 KB, patch)
2010-06-23 12:44 EDT, Carl Anderson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Fernandez CLA 2010-06-10 19:52:55 EDT
Build Identifier: 

SUMMARY:

When I create a new Dynamic Web Project I can specify the EAR name first.

Let's say HelloEAR

I decide to copy that name to Project Name and remove the EAR extension.

I still get the message:

The EAR project name, "HelloEAR", can not be the same as the project name.

Reproducible: Always

Steps to Reproduce:
1. Launch Helios. Goto Java EE perspective
2. Launch Dynamic Web Project wizard
3. Check Add Project to an EAR
4. Name EAR project
5. Copy what you named for EAR project name and paste in project name:
6. Remove EAR suffix.

Error remaains
Comment 1 Carl Anderson CLA 2010-06-10 22:33:19 EDT
This is actually a bad problem.  Once an invalid project name occurs, it keeps the invalid project name, irregardless of what is typed in.

The problematic code is found in FacetProjectCreationDataModelProvider, starting with line 136:

final String projectName = (String) event.getProperty();
IStatus status = getDataModel().validateProperty(FACET_PROJECT_NAME);
if( status.isOK() ){
getDataModel().setProperty(FACET_PROJECT_NAME, projectName);
fpjwc.setProjectName( projectName );
}

As is visible in that snippet, once the current FACET_PROJECT_NAME causes a non-OK status to be returned, it will not be updated any more.
Comment 2 Carl Anderson CLA 2010-06-10 23:01:02 EDT
The more I look into this, the worse this scenario gets.  Here's a more vibrant illustration of this issue:

Bring up any of the Java EE wizards.  
Click "Add to EAR" and specify foo for the EAR project name.
Specify foo for the project name, and you will see the error.
Change the project name to bar.  The error is still there.
Change the EAR project name to barEAR.  The error goes away.
Press finish, and it will create:

barEAR
foo

So, even though you had bar as the project name when you pressed finish, you end up with a project named foo!!!

I am raising the priority to P1, since this needs to be fixed ASAP.  (Since the final build for WTP 3.2 was earlier this week, this should be fixed in WTP 3.2.1.)
Comment 3 Carl Anderson CLA 2010-06-10 23:07:00 EDT
It appears that the code in question was the 'fix' for bug 294671.
Comment 4 Andrew Fernandez CLA 2010-06-10 23:43:26 EDT
Also noted issue today in comment 2 with project name not updating by clicking Next to get to WebContent name and it had old name...
Comment 5 Konstantin Komissarchik CLA 2010-06-11 12:49:37 EDT
This does sound like a bad issue, but the class in question is not in the Faceted Project Framework. Either jst.j2ee or perhaps the general wst.common component.
Comment 6 Carl Anderson CLA 2010-06-17 14:41:11 EDT
I'll do the initial investigation for this.
Comment 7 Carl Anderson CLA 2010-06-23 12:44:38 EDT
Created attachment 172533 [details]
Set the model property, then check for error
Comment 8 Carl Anderson CLA 2010-06-23 12:48:25 EDT
The problem with the patch for bug 294671 is that it does not set the new project name in the model, ever.  The underlying problem that was causing trouble was the setting of the FacetedProjectWorkingCopy's project name.

By limiting the validity check to the FacetedProjectWorkingCopy.setProjectName(), that does the following:
It allows the model's project name to be properly updated.  The model will still not validate properly, and thus any operation based on the model should be prevented from running while the value is not valid.

Since the operation will not run, the lack of setting the project name on the FacetedProjectWorkingCopy should not be an issue.  Once the validation problem is resolved, the project name will be set properly.
Comment 9 Carl Anderson CLA 2010-06-23 12:58:07 EDT
For the record, I approve of my change.
Comment 10 Carl Anderson CLA 2010-06-23 12:58:55 EDT
Committed to HEAD for WTP 3.2.1.
Comment 11 Konstantin Komissarchik CLA 2010-06-23 13:07:52 EDT
> By limiting the validity check to the
> FacetedProjectWorkingCopy.setProjectName(), that does the following:
> It allows the model's project name to be properly updated.  The model will
> still not validate properly, and thus any operation based on the model should
> be prevented from running while the value is not valid.

Could you elaborate on what happens if setProjectName() is called? I looked at this thread and the linked bug, but didn't find any specifics. The working copy is accessible to facets in the wizard for their own action validation. If they cannot get the correct project name from the working copy in some cases, that could be problematic.

If this check is essentially a workaround for a bug when calling setProjectName in some cases, I'd like to see if we can fix the underlying problem instead.
Comment 12 Carl Anderson CLA 2010-06-23 14:02:36 EDT
When fpjwc.setProjectName() is called with the existing EAR name (see bug 294671c#0 ), the fpjwc.project gets set to the existing EAR project.  The next time fpjwc.setProjectName() is called, since the project is set, an IllegalArgumentException is thrown.  Things go downhill from there.  (see bug 294671c#0 for more details).