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.

View | Details | Raw Unified | Return to bug 199642
Collapse All | Expand All

(-)a/openide.filesystems/apichanges.xml (+18 lines)
Lines 49-54 Link Here
49
        <apidef name="filesystems">Filesystems API</apidef>
49
        <apidef name="filesystems">Filesystems API</apidef>
50
    </apidefs>
50
    </apidefs>
51
    <changes>
51
    <changes>
52
        <change id="FileObject.getMIMEType...">
53
            <api name="filesystems"/>
54
            <summary>FileObject.getMIMEType(String... withinMIMETypes)</summary>
55
            <version major="7" minor="50"/>
56
            <date day="4" month="8" year="2011"/>
57
            <author login="jtulach"/>
58
            <compatibility addition="yes"/>
59
            <description>
60
                <p>
61
                    Introducing <a href="@TOP@/org/openide/filesystems/FileObject.html#getMIMEType(java.lang.String...)">
62
                    FileObject.getMIMEType(String...)    
63
                    </a> that can be overriden by different implementations
64
                    of file system API.
65
                </p>
66
            </description>
67
            <class package="org.openide.filesystems" name="FileObject"/>
68
            <issue number="199642"/>
69
        </change>
52
        <change id="getConfigObject">
70
        <change id="getConfigObject">
53
            <api name="filesystems"/>
71
            <api name="filesystems"/>
54
            <summary>FileUtil.getConfigObject</summary>
72
            <summary>FileUtil.getConfigObject</summary>
(-)a/openide.filesystems/manifest.mf (-1 / +1 lines)
Lines 2-6 Link Here
2
OpenIDE-Module: org.openide.filesystems
2
OpenIDE-Module: org.openide.filesystems
3
OpenIDE-Module-Localizing-Bundle: org/openide/filesystems/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/openide/filesystems/Bundle.properties
4
OpenIDE-Module-Layer: org/openide/filesystems/resources/layer.xml
4
OpenIDE-Module-Layer: org/openide/filesystems/resources/layer.xml
5
OpenIDE-Module-Specification-Version: 7.49
5
OpenIDE-Module-Specification-Version: 7.50
6
6
(-)a/openide.filesystems/src/org/openide/filesystems/FileObject.java (+17 lines)
Lines 571-576 Link Here
571
        String mimeType = FileUtil.getMIMEType(this);
571
        String mimeType = FileUtil.getMIMEType(this);
572
        return  mimeType == null ? "content/unknown" : mimeType;  //NOI18N
572
        return  mimeType == null ? "content/unknown" : mimeType;  //NOI18N
573
    }
573
    }
574
    
575
    /** Resolves MIME type from the list of acceptable ones. By default
576
     * calls {@link FileUtil#getMIMEType(org.openide.filesystems.FileObject, java.lang.String[])},
577
     * but subclasses may override this method to be more effective.
578
     * 
579
     * @param withinMIMETypes 
580
     *   A hint to the underlaying infrastructure to 
581
     *   limit the search to given array of MIME types. 
582
     * @return the MIME type for the FileObject, or <code>null</code> if 
583
     *   the FileObject is unrecognized. It may return {@code content/unknown} instead of {@code null}.
584
     *   It is possible for the resulting MIME type to not be a member of given <code>withinMIMETypes</code>
585
     *   list.
586
     * @since 7.50
587
     */
588
    public String getMIMEType(String... withinMIMETypes) {
589
        return FileUtil.getMIMEType(this, withinMIMETypes);
590
    }
574
591
575
    /** Get the size of the file.
592
    /** Get the size of the file.
576
    * @return the size of the file in bytes or zero if the file does not contain data (does not
593
    * @return the size of the file in bytes or zero if the file does not contain data (does not
(-)a/openide.filesystems/test/unit/src/org/openide/filesystems/FileUtilTest.java (-3 / +3 lines)
Lines 381-387 Link Here
381
        FileObject fo = FileUtil.createData(testFolder, "fo1.mime1");
381
        FileObject fo = FileUtil.createData(testFolder, "fo1.mime1");
382
        String[] withinMIMETypes = null;
382
        String[] withinMIMETypes = null;
383
        try {
383
        try {
384
            FileUtil.getMIMEType(fo, withinMIMETypes);
384
            fo.getMIMEType(withinMIMETypes);
385
            fail("FileUtil.getMIMEType(fo, null) should throw IllegalArgumentException.");
385
            fail("FileUtil.getMIMEType(fo, null) should throw IllegalArgumentException.");
386
        } catch (NullPointerException npe) {
386
        } catch (NullPointerException npe) {
387
            // exception correctly thrown
387
            // exception correctly thrown
Lines 389-395 Link Here
389
        
389
        
390
        fo = FileUtil.createData(testFolder, "fo2.mime1");
390
        fo = FileUtil.createData(testFolder, "fo2.mime1");
391
        withinMIMETypes = new String[0];
391
        withinMIMETypes = new String[0];
392
        FileUtil.getMIMEType(fo, withinMIMETypes);
392
        fo.getMIMEType(withinMIMETypes);
393
        assertTrue("Resolver should be queried if array of desired MIME types is empty.", MyResolver.wasQueried());
393
        assertTrue("Resolver should be queried if array of desired MIME types is empty.", MyResolver.wasQueried());
394
        
394
        
395
        fo = FileUtil.createData(testFolder, "fo3.mime1");
395
        fo = FileUtil.createData(testFolder, "fo3.mime1");
Lines 404-410 Link Here
404
404
405
        fo = FileUtil.createData(testFolder, "fo5.mime1");
405
        fo = FileUtil.createData(testFolder, "fo5.mime1");
406
        withinMIMETypes = new String[]{"mime1", "mime2"};
406
        withinMIMETypes = new String[]{"mime1", "mime2"};
407
        FileUtil.getMIMEType(fo, withinMIMETypes);
407
        fo.getMIMEType(withinMIMETypes);
408
        assertTrue("Resolver should be queried if both items in array of desired MIME types matches MIMEResolver.getMIMETypes.", MyResolver.wasQueried());
408
        assertTrue("Resolver should be queried if both items in array of desired MIME types matches MIMEResolver.getMIMETypes.", MyResolver.wasQueried());
409
    }
409
    }
410
410
(-)a/openide.filesystems/test/unit/src/org/openide/filesystems/MIMESupportTest.java (-2 / +2 lines)
Lines 396-402 Link Here
396
        assertEquals(3, Lookup.getDefault().lookupAll(MIMEResolver.class).size());
396
        assertEquals(3, Lookup.getDefault().lookupAll(MIMEResolver.class).size());
397
397
398
        FileObject fo = FileUtil.createData(FileUtil.createMemoryFileSystem().getRoot(), "file.a");
398
        FileObject fo = FileUtil.createData(FileUtil.createMemoryFileSystem().getRoot(), "file.a");
399
        String mimeType = FileUtil.getMIMEType(fo, "b/b");
399
        String mimeType = fo.getMIMEType("b/b");
400
        assertEquals("content/unknown", mimeType);
400
        assertEquals("content/unknown", mimeType);
401
        mimeType = FileUtil.getMIMEType(fo, "a/a");
401
        mimeType = FileUtil.getMIMEType(fo, "a/a");
402
        assertEquals("a/a", mimeType);
402
        assertEquals("a/a", mimeType);
Lines 407-413 Link Here
407
407
408
        //#161340 - do not cache text/xml if it is falback value
408
        //#161340 - do not cache text/xml if it is falback value
409
        FileObject fo1 = FileUtil.createData(FileUtil.createMemoryFileSystem().getRoot(), "file.xml");
409
        FileObject fo1 = FileUtil.createData(FileUtil.createMemoryFileSystem().getRoot(), "file.xml");
410
        mimeType = FileUtil.getMIMEType(fo1, "a/a");
410
        mimeType = fo1.getMIMEType("a/a");
411
        assertEquals("Fallback for xml failed.", "text/xml", mimeType);
411
        assertEquals("Fallback for xml failed.", "text/xml", mimeType);
412
        mimeType = FileUtil.getMIMEType(fo1);
412
        mimeType = FileUtil.getMIMEType(fo1);
413
        assertEquals("Fallback MIME type for xml should not be cached.", "xml/xml", mimeType);
413
        assertEquals("Fallback MIME type for xml should not be cached.", "xml/xml", mimeType);
(-)a/openide.loaders/nbproject/project.xml (-1 / +1 lines)
Lines 122-128 Link Here
122
                    <build-prerequisite/>
122
                    <build-prerequisite/>
123
                    <compile-dependency/>
123
                    <compile-dependency/>
124
                    <run-dependency>
124
                    <run-dependency>
125
                        <specification-version>7.19</specification-version>
125
                        <specification-version>7.50</specification-version>
126
                    </run-dependency>
126
                    </run-dependency>
127
                </dependency>
127
                </dependency>
128
                <dependency>
128
                <dependency>
(-)a/openide.loaders/src/org/openide/loaders/ExtensionList.java (-1 / +1 lines)
Lines 169-175 Link Here
169
        }
169
        }
170
170
171
        if (mimeTypes != null) {
171
        if (mimeTypes != null) {
172
            String mime = FileUtil.getMIMEType(fo, mimeTypes.toArray(new String[0]));
172
            String mime = fo.getMIMEType(mimeTypes.toArray(new String[0]));
173
            if (mimeTypes.contains(mime)) {
173
            if (mimeTypes.contains(mime)) {
174
                return true;
174
                return true;
175
            }
175
            }

Return to bug 199642