Skip to content

Commit

Permalink
Remove pre-apache NetBeans 8.2 plugin portal from settings.
Browse files Browse the repository at this point in the history
plugins haven't been updated for a long time and are of limited use,
some require pack200, others broke for other reasons.

small language level cleanup, mostly try-with-resource blocks.
  • Loading branch information
mbien committed Feb 10, 2024
1 parent ff360b6 commit 46a55c5
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,86 +45,65 @@
@ServiceProvider(service=AutoupdateClusterCreator.class)
public final class NetBeansClusterCreator extends AutoupdateClusterCreator {
protected @Override File findCluster(String clusterName) {
AtomicReference<File> parent = new AtomicReference<File>();
File conf = findConf(parent, new ArrayList<File>());
AtomicReference<File> 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<File> parent, List<? super File> 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<File> parent = new AtomicReference<File>();
List<File> clusters = new ArrayList<File>();
AtomicReference<File> parent = new AtomicReference<>();
List<File> 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 ();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 ());
}
Expand All @@ -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 () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,6 @@
<attr name="instanceOf" stringvalue="org.netbeans.spi.autoupdate.UpdateProvider"/>
<attr name="instanceCreate" methodvalue="org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalogFactory.createUpdateProvider"/>
</file>

<file name="82pluginportal-update-provider.instance">
<attr name="displayName" bundlevalue="org.netbeans.modules.updatecenters.resources.Bundle#Services/AutoupdateType/82pluginportal-update-provider.instance"/>
<attr name="iconBase" stringvalue="org/netbeans/modules/updatecenters/resources/updateAction.gif"/>
<attr name="url" bundlevalue="org.netbeans.modules.updatecenters.resources.Bundle#URL_82PluginPortal"/>
<attr name="category" stringvalue="STANDARD"/>
<attr name="enabled" boolvalue="false"/>
<attr name="instanceOf" stringvalue="org.netbeans.spi.autoupdate.UpdateProvider"/>
<attr name="instanceCreate" methodvalue="org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalogFactory.createUpdateProvider"/>
</file>

<file name="3rdparty.instance">
<attr name="displayName" bundlevalue="org.netbeans.modules.updatecenters.resources.Bundle#3rdparty"/>
Expand Down

0 comments on commit 46a55c5

Please sign in to comment.