Changeset 30734 in osm


Ignore:
Timestamp:
2014-10-18T16:48:52+02:00 (10 years ago)
Author:
donvip
Message:

[josm_geotools] fix sonar issues

Location:
applications/editors/josm/plugins/geotools
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/geotools/.project

    r28593 r30734  
    1313        </buildSpec>
    1414        <natures>
     15                <nature>org.sonar.ide.eclipse.core.sonarNature</nature>
    1516                <nature>org.eclipse.jdt.core.javanature</nature>
    1617        </natures>
  • applications/editors/josm/plugins/geotools/build.xml

    r30416 r30734  
    55    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    66    <property name="plugin.main.version" value="7001"/>
    7        
     7   
    88    <property name="plugin.author" value="Don-vip"/>
    99    <property name="plugin.class" value="org.openstreetmap.josm.plugins.geotools.GeoToolsPlugin"/>
     
    1717    <!-- ** include targets that all plugins have in common ** -->
    1818    <import file="../build-common.xml"/>
    19        
     19   
    2020    <!--
    2121    **********************************************************
     
    2424    -->
    2525    <target name="post-dist">
    26         <move file="${plugin.jar}" todir="${plugin.build.dir}" />
    27         <jar destfile="${plugin.jar}" filesetmanifest="merge">
     26        <move file="${plugin.jar}" todir="${plugin.build.dir}" />
     27        <jar destfile="${plugin.jar}" filesetmanifest="merge">
    2828            <fileset dir="jar"/>
    29                 <zipfileset src="${plugin.build.dir}/${ant.project.name}.jar">
     29            <zipfileset src="${plugin.build.dir}/${ant.project.name}.jar">
    3030                <exclude name="*.class"/>
    31                         <exclude name="*.html"/>
     31                <exclude name="*.html"/>
    3232                <exclude name="META-INF/**/*"/>
    3333                <exclude name="javax/*.txt"/>
    34                 </zipfileset>
    35             <zipfileset src="${plugin.build.dir}/${ant.project.name}.jar">
    36                 <include name="META-INF/MANIFEST.MF"/>
    37                 <include name="META-INF/*.jai"/>
    38             </zipfileset>
    39         </jar>
    40         <delete file="${plugin.build.dir}/${ant.project.name}.jar" />
     34            </zipfileset>
     35            <zipfileset src="${plugin.build.dir}/${ant.project.name}.jar">
     36                <include name="META-INF/MANIFEST.MF"/>
     37                <include name="META-INF/*.jai"/>
     38            </zipfileset>
     39        </jar>
     40        <delete file="${plugin.build.dir}/${ant.project.name}.jar" />
    4141    </target>
    4242</project>
  • applications/editors/josm/plugins/geotools/src/org/openstreetmap/josm/plugins/geotools/GeoToolsPlugin.java

    r30569 r30734  
    1717import com.sun.media.jai.imageioimpl.ImageReadWriteSpi;
    1818
     19/**
     20 * GeoTools plugin, bringing this library to other JOSM plugins.
     21 */
    1922public class GeoToolsPlugin extends Plugin {
     23
     24    /**
     25     * Constructs a new {@code GeoToolsPlugin}.
     26     * @param info plugin information
     27     */
    2028    public GeoToolsPlugin(PluginInformation info) {
    2129        super(info);
     
    2937        // See https://www.java.net/node/666373
    3038        System.setProperty("com.sun.media.jai.disableMediaLib", "true");
    31                
     39
    3240        // As the JAI jars are bundled in the geotools plugin, JAI initialization does not work,
    3341        // so we need to perform the tasks described here ("Initialization and automatic loading of registry objects"):
     
    3543        OperationRegistry registry = JAI.getDefaultInstance().getOperationRegistry();
    3644        if (registry == null) {
    37             System.err.println("geotools: error in JAI initialization. Cannot access default operation registry");
     45            Main.error("geotools: error in JAI initialization. Cannot access default operation registry");
    3846        } else {
    3947            // Update registry with com.sun.media.jai.imageioimpl.ImageReadWriteSpi (only class listed javax.media.jai.OperationRegistrySpi)
    40             // it would be safer to parse this file instead, but a JAI update is very unlikely as it has not been modified since 2005 
     48            // it would be safer to parse this file instead, but a JAI update is very unlikely as it has not been modified since 2005
    4149            new ImageReadWriteSpi().updateRegistry(registry);
    4250
    43             // Update registry with GeoTools registry file
    44             InputStream in = GeoToolsPlugin.class.getResourceAsStream("/META-INF/registryFile.jai");
    45             if (in == null) {
    46                 System.err.println("geotools: error in JAI initialization. Cannot access META-INF/registryFile.jai");
    47             } else {
    48                 try {
     51            // Update registry with GeoTools registry file
     52            try (InputStream in = GeoToolsPlugin.class.getResourceAsStream("/META-INF/registryFile.jai")) {
     53                if (in == null) {
     54                    Main.error("geotools: error in JAI initialization. Cannot access META-INF/registryFile.jai");
     55                } else {
    4956                    registry.updateFromStream(in);
    50                 } catch (IOException e) {
    51                     System.err.println("geotools: error in JAI initialization. Cannot update default operation registry");
    5257                }
    53                 try {
    54                     in.close();
    55                 } catch (IOException e) {
    56                     System.err.println("geotools: error in JAI initialization. Cannot close input stream");
    57                 }
     58            } catch (IOException e) {
     59                Main.error("geotools: error in JAI initialization: "+e.getMessage());
    5860            }
    59            
    60             // Print JAI registry contents
    61             //for (String mode : RegistryMode.getModeNames()) {
    62             //    System.out.println("geotools: JAI mode "+mode+": "+Arrays.toString(registry.getDescriptorNames(mode)));
    63             //}
    6461        }
    6562    }
    66    
     63
    6764    private void initGeoTools() {
    6865        // Force Axis order. Fix #8248
Note: See TracChangeset for help on using the changeset viewer.