diff --git a/nb/updatecenters/src/org/netbeans/modules/updatecenters/resources/Bundle.properties b/nb/updatecenters/src/org/netbeans/modules/updatecenters/resources/Bundle.properties index bc4a0eb8a5c2..fdf5547454c4 100644 --- a/nb/updatecenters/src/org/netbeans/modules/updatecenters/resources/Bundle.properties +++ b/nb/updatecenters/src/org/netbeans/modules/updatecenters/resources/Bundle.properties @@ -25,14 +25,11 @@ OpenIDE-Module-Short-Description=Declares NetBeans autoupdate centers. Services/AutoupdateType/distribution-update-provider.instance=NetBeans Distribution Services/AutoupdateType/pluginportal-update-provider.instance=NetBeans Plugin Portal -Services/AutoupdateType/82pluginportal-update-provider.instance=NetBeans 8.2 Plugin Portal #NOI18N URL_Distribution=@@metabuild.DistributionURL@@ #NOI18N URL_PluginPortal=@@metabuild.PluginPortalURL@@ -#NOI18N -URL_82PluginPortal=http://updates.netbeans.org/netbeans/updates/8.2/uc/final/distribution/catalog.xml.gz 3rdparty=Third Party Libraries #NOI18N diff --git a/nb/updatecenters/src/org/netbeans/modules/updatecenters/resources/NetBeansClusterCreator.java b/nb/updatecenters/src/org/netbeans/modules/updatecenters/resources/NetBeansClusterCreator.java index 7a7949df5131..ae4917e79f92 100644 --- a/nb/updatecenters/src/org/netbeans/modules/updatecenters/resources/NetBeansClusterCreator.java +++ b/nb/updatecenters/src/org/netbeans/modules/updatecenters/resources/NetBeansClusterCreator.java @@ -45,86 +45,65 @@ @ServiceProvider(service=AutoupdateClusterCreator.class) public final class NetBeansClusterCreator extends AutoupdateClusterCreator { protected @Override File findCluster(String clusterName) { - AtomicReference parent = new AtomicReference(); - File conf = findConf(parent, new ArrayList()); + AtomicReference parent = new AtomicReference<>(); + File conf = findConf(parent, new ArrayList<>()); return conf != null && conf.isFile() && canWrite (conf) ? new File(parent.get(), clusterName) : null; } private static File findConf(AtomicReference parent, List clusters) { String nbdirs = System.getProperty("netbeans.dirs"); if (nbdirs != null) { - StringTokenizer tok = new StringTokenizer(nbdirs, File.pathSeparator); // NOI18N - while (tok.hasMoreElements()) { - File cluster = new File(tok.nextToken()); - clusters.add(cluster); - if (!cluster.exists()) { - continue; - } - - - - if (parent.get() == null) { - parent.set(cluster.getParentFile()); - } - - if (!parent.get().equals(cluster.getParentFile())) { - // we can handle only case when all clusters are in - // the same directory these days - return null; + StringTokenizer tok = new StringTokenizer(nbdirs, File.pathSeparator); // NOI18N + while (tok.hasMoreElements()) { + File cluster = new File(tok.nextToken()); + clusters.add(cluster); + if (!cluster.exists()) { + continue; + } + if (parent.get() == null) { + parent.set(cluster.getParentFile()); + } + if (!parent.get().equals(cluster.getParentFile())) { + // we can handle only case when all clusters are in + // the same directory these days + return null; + } } } - } return new File(new File(parent.get(), "etc"), "netbeans.clusters"); } protected @Override File[] registerCluster(String clusterName, File cluster) throws IOException { - AtomicReference parent = new AtomicReference(); - List clusters = new ArrayList(); + AtomicReference parent = new AtomicReference<>(); + List clusters = new ArrayList<>(); File conf = findConf(parent, clusters); assert conf != null; clusters.add(cluster); Properties p = new Properties(); - InputStream is = new FileInputStream(conf); - try{ + try(InputStream is = new FileInputStream(conf)) { p.load(is); - } finally { - is.close(); } if (!p.containsKey(clusterName)) { - OutputStream os = new FileOutputStream(conf, true); - try { + try (OutputStream os = new FileOutputStream(conf, true)) { os.write('\n'); os.write(clusterName.getBytes()); os.write('\n'); - } finally { - os.close(); } } return clusters.toArray(new File[0]); } public static boolean canWrite (File f) { - // workaround the bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4420020 + // workaround the bug: https://bugs.openjdk.org/browse/JDK-4420020 if (Utilities.isWindows ()) { - FileWriter fw = null; - try { - fw = new FileWriter (f, true); + try (FileWriter fw = new FileWriter(f, true)) { Logger.getLogger(NetBeansClusterCreator.class.getName()).log(Level.FINE, "{0} has write permission", f); + return true; } catch (IOException ioe) { - // just check of write permission Logger.getLogger (NetBeansClusterCreator.class.getName ()).log (Level.FINE, f + " has no write permission", ioe); return false; - } finally { - try { - if (fw != null) { - fw.close (); - } - } catch (IOException ex) { - Logger.getLogger (NetBeansClusterCreator.class.getName ()).log (Level.INFO, ex.getLocalizedMessage (), ex); - } } - return true; } else { return f.canWrite (); } diff --git a/nb/updatecenters/src/org/netbeans/modules/updatecenters/resources/NetBeansKeyStoreProvider.java b/nb/updatecenters/src/org/netbeans/modules/updatecenters/resources/NetBeansKeyStoreProvider.java index c14e0332e790..c34f760d40d1 100644 --- a/nb/updatecenters/src/org/netbeans/modules/updatecenters/resources/NetBeansKeyStoreProvider.java +++ b/nb/updatecenters/src/org/netbeans/modules/updatecenters/resources/NetBeansKeyStoreProvider.java @@ -21,7 +21,6 @@ import java.io.File; import java.io.FileInputStream; -import java.io.IOException; import java.io.InputStream; import java.security.KeyStore; import java.util.logging.Level; @@ -39,6 +38,7 @@ public final class NetBeansKeyStoreProvider implements KeyStoreProvider { public static final String KS_FILE_PATH = "core/ide.ks"; private static final String KS_DEFAULT_PASSWORD = "open4all"; + @Override public KeyStore getKeyStore() { return getKeyStore (getKeyStoreFile (), getPassword ()); } @@ -54,28 +54,17 @@ private static File getKeyStoreFile () { * @param password */ private static KeyStore getKeyStore(File file, String password) { - if (file == null) return null; - KeyStore keyStore = null; - InputStream is = null; - - try { - - is = new FileInputStream (file); - - keyStore = KeyStore.getInstance (KeyStore.getDefaultType ()); - keyStore.load (is, password.toCharArray ()); - + if (file == null) { + return null; + } + try (InputStream is = new FileInputStream(file)) { + KeyStore keyStore = KeyStore.getInstance (KeyStore.getDefaultType()); + keyStore.load (is, password.toCharArray()); + return keyStore; } catch (Exception ex) { Logger.getLogger ("global").log (Level.INFO, ex.getMessage (), ex); - } finally { - try { - if (is != null) is.close (); - } catch (IOException ex) { - assert false : ex; - } } - - return keyStore; + return null; } private static String getPassword () { diff --git a/nb/updatecenters/src/org/netbeans/modules/updatecenters/resources/mf-layer.xml b/nb/updatecenters/src/org/netbeans/modules/updatecenters/resources/mf-layer.xml index bacad2f70e49..5e3480434110 100644 --- a/nb/updatecenters/src/org/netbeans/modules/updatecenters/resources/mf-layer.xml +++ b/nb/updatecenters/src/org/netbeans/modules/updatecenters/resources/mf-layer.xml @@ -45,16 +45,6 @@ - - - - - - - - - -