Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 353146 - Make Persistent Wizard: Cannot select mapping file from the folder other than META-INF
Summary: Make Persistent Wizard: Cannot select mapping file from the folder other than...
Status: VERIFIED FIXED
Alias: None
Product: Dali JPA Tools
Classification: WebTools
Component: JPA (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.0.1   Edit
Assignee: Nan Li CLA
QA Contact:
URL:
Whiteboard: fix_ready
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-26 14:15 EDT by Nan Li CLA
Modified: 2011-11-01 18:29 EDT (History)
3 users (show)

See Also:
karenfbutzke: review+
neil.hauge: review+


Attachments
Stack Trace (3.56 KB, text/plain)
2011-07-26 14:16 EDT, Nan Li CLA
no flags Details
Proposed Patch (5.74 KB, patch)
2011-07-27 16:38 EDT, Nan Li CLA
no flags Details | Diff
Proposed Patch (4.80 KB, patch)
2011-08-02 17:52 EDT, Nan Li CLA
neil.hauge: iplog+
Details | Diff
proposed patch against 3.0 maintenance (2.76 KB, text/plain)
2011-08-03 20:15 EDT, Karen Butzke CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nan Li CLA 2011-07-26 14:15:20 EDT
Build Identifier: I20110526-1708

1. Create a mapping file in a source folder other than META-INF
2. Open make persistent wizard and select Add to XML mapping file radio button
3. Click Browse button and select the mapping file created in step 1

The value cannot be set to the text field with the exception below. Our code only accepts the mapping file from META-INF folder, but mapping files in the sources folders should be all valid to set, just like what the selecting mapping file dialog shows. 

java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.String.substring(Unknown Source)
	at java.lang.String.substring(Unknown Source)
	at org.eclipse.jpt.jpa.ui.internal.wizards.SelectJpaOrmMappingFileDialog.removeRedundantSegmentFromName(SelectJpaOrmMappingFileDialog.java:130)
	at org.eclipse.jpt.jpa.ui.internal.wizards.SelectJpaOrmMappingFileDialog.getChosenName(SelectJpaOrmMappingFileDialog.java:104)
	at org.eclipse.jpt.jpa.ui.internal.wizards.JpaMakePersistentWizardPage.mappingFileBrowseButtonPressed(JpaMakePersistentWizardPage.java:295)

Full stack trace is attached. 

Reproducible: Always
Comment 1 Nan Li CLA 2011-07-26 14:16:17 EDT
Created attachment 200386 [details]
Stack Trace
Comment 2 Nan Li CLA 2011-07-26 14:37:55 EDT
The root problem should be in the first line of the method below of SelectJpaOrmMappingFileDialog class. It assumes the input is only from META-INF folder.

private String removeRedundantSegmentFromName(String input) {
	String output = input.substring(input.indexOf(META_INF));			 
	output = output.replace(File.separatorChar, SLASH);
	return output;
}
Comment 3 Nan Li CLA 2011-07-27 16:38:19 EDT
Created attachment 200476 [details]
Proposed Patch
Comment 4 Karen Butzke CLA 2011-08-02 16:32:24 EDT
Nan, I have a few suggestions on your patch:

1. You added a tooltip to the new button in the SelectJpaOrmMappingFileDialog. This text needs to be externalized to JptUiMessages.
2. SelectJpaOrmMappingFileDialog.getChosenName(IProject) you don't need to pass in the IProject because it has already been passed in and stored in the constructor.

Functionally this patch looks good to me
Comment 5 Nan Li CLA 2011-08-02 17:52:17 EDT
Created attachment 200765 [details]
Proposed Patch

Incorporated Karen's comments
Comment 6 Karen Butzke CLA 2011-08-03 09:06:28 EDT
Looks good! I have checked this in to HEAD. Neil, do you think we should put this in 3.0.1 maintenance as well?
Comment 7 Neil Hauge CLA 2011-08-03 10:23:39 EDT
(In reply to comment #6)
> Neil, do you think we should put this in 3.0.1 maintenance as well?

The severity is borderline, but if the fix is low-risk and solid, I say we push into maintenance.
Comment 8 Karen Butzke CLA 2011-08-03 20:15:01 EDT
Created attachment 200869 [details]
proposed patch against 3.0 maintenance

I've attached a patch against the maintenance stream that is the same minus the tooltip text that was added to a resource bundle.
Comment 9 Karen Butzke CLA 2011-08-04 07:36:17 EDT
checked in to 3_0_maintenance
Comment 10 Jolene Moffitt CLA 2011-08-10 09:57:15 EDT
Verified in Build I-3.4.0-20110805150738 

Verified user can select mapping file from the folder other than META-INF in the Make Persistent Wizard without error.  See the link to view
test steps for verification. http://wiki.eclipse.org/Dali_3.0.1