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 153202

Summary: Add API for programmatic way to add new extension for interested mime-type
Product: platform Reporter: Jiri Skrivanek <jskrivanek>
Component: FilesystemsAssignee: Jiri Skrivanek <jskrivanek>
Status: VERIFIED FIXED    
Severity: blocker CC: apireviews, vv159170
Priority: P2 Keywords: API, API_REVIEW_FAST
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:
Bug Depends on:    
Bug Blocks: 153204    
Attachments: FileUtil patch.

Description Jiri Skrivanek 2008-11-14 09:40:12 UTC
There should exists a possibility to programatically add an extension to be recognized as certain MIME type. Now it is
achievable only in Tools > Options > Miscellaneous > Files.
Comment 1 Jiri Skrivanek 2008-11-26 09:12:36 UTC
Please, review changes in FileUtil. Method FileUtil.setMIMEType(String extension, String mimeType) was un-deprecated.
New implementation persistently registers file extension for specified MIME type. It is stored in
userdir/config/Services/MIMEResolver. From previous implementation is kept the fact that files with the xml extension
are by default resolved as text/xml MIME type even no MIMEResolver is registered.
Also added method FileUtil.getMIMETypeExtensions(String mimeType) to get list of file extensions associated with
specified MIME type.
Comment 2 Jiri Skrivanek 2008-11-26 09:13:47 UTC
Created attachment 74162 [details]
FileUtil patch.
Comment 3 Vladimir Voskresensky 2008-11-29 19:08:21 UTC
VV1: We need support not only for adding new extension to be recognized as C++ file, but removing as well. 
Comment 4 Jiri Skrivanek 2008-12-01 07:29:53 UTC
> VV1: We need support not only for adding new extension to be recognized as C++ file, but removing as well.

For example FileUtil.setMIMEType("mycpp", null) deregisters the mycpp extension.
Comment 5 Vladimir Voskresensky 2008-12-01 08:53:22 UTC
if this info in javadoc and apichanges => I'm fine with it
Thanks
Comment 6 Jiri Skrivanek 2008-12-01 11:53:48 UTC
It is in javadoc, I will add it to apichanges.
Comment 7 Jesse Glick 2008-12-01 17:06:16 UTC
"It is in javadoc, I will add it to apichanges." - all details about an API should be kept in the Javadoc.
apichanges.xml entries should be short and describe only what has changed, in the case of an existing API; or in the
case of a new API, give a very brief summary of its purpose. An apichanges entry exists so that a reader can decide
whether the change is relevant to their application, but Javadoc must be read to actually use the API.
Comment 8 Jiri Skrivanek 2008-12-03 08:09:32 UTC
If there are no other complains, it will be integrated to 7.0M2.
Comment 9 Jiri Skrivanek 2008-12-19 09:24:17 UTC
Implemented.
http://hg.netbeans.org/core-main/rev/fe4dc8c2623f
Comment 10 Quality Engineering 2008-12-22 15:11:07 UTC
Integrated into 'main-golden', will be available in build *200812221122* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/fe4dc8c2623f
User: Jiri Skrivanek <jskrivanek@netbeans.org>
Log: #153202 - Method FileUtil.setMIMEType(String extension, String mimeType) resurrected to register file extension for specified MIME type. It is persisted in userdir contrary to previous implementation. Added method FileUtil.getMIMETypeExtensions(String mimeType) to get list of file extensions associated with specified MIME type.