### Eclipse Workspace Patch 1.0 #P org.eclipse.update.core Index: src/org/eclipse/update/internal/core/NioHelper.java =================================================================== RCS file: src/org/eclipse/update/internal/core/NioHelper.java diff -N src/org/eclipse/update/internal/core/NioHelper.java --- src/org/eclipse/update/internal/core/NioHelper.java 3 May 2006 17:34:57 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.update.internal.core; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.channels.FileChannel; - - -public class NioHelper { - // This method must be in a seperate class file otherwise a NIO class not found error - // will be thrown loading the calling class. We put it in it's own class so the - // caller can catch the error/exception. - static void copyFile(File src, File dst) throws IOException { - FileChannel in = null; - FileChannel out = null; - - try { - in = new FileInputStream(src).getChannel(); - out = new FileOutputStream(dst).getChannel(); - in.transferTo( 0, in.size(), out); - } finally { - if (in != null) - in.close(); - if (out != null) - out.close(); - } - } - - -} Index: src/org/eclipse/update/internal/core/JarDeltaInstallHandler.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/core/JarDeltaInstallHandler.java,v retrieving revision 1.2 diff -u -r1.2 JarDeltaInstallHandler.java --- src/org/eclipse/update/internal/core/JarDeltaInstallHandler.java 3 May 2006 17:34:57 -0000 1.2 +++ src/org/eclipse/update/internal/core/JarDeltaInstallHandler.java 4 May 2006 20:32:04 -0000 @@ -11,13 +11,16 @@ package org.eclipse.update.internal.core; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.net.URI; -import java.net.URISyntaxException; +import java.io.OutputStream; +import java.net.MalformedURLException; +import java.net.URL; import java.util.Date; import java.util.Enumeration; import java.util.jar.JarFile; @@ -48,27 +51,27 @@ ContentReference[] oldReferences = oldFeature.getFeatureContentProvider().getPluginEntryContentReferences(oldPlugin, null); ContentReference[] newReferences = feature.getFeatureContentProvider().getPluginEntryContentReferences(newPlugin, null); - - URI oldURI = null; + + URL oldURI = null; try { - oldURI = new URI(consumer.getFeature().getSite().getURL().getPath() + + oldURI = new URL(consumer.getFeature().getSite().getURL().getPath() + Site.DEFAULT_PLUGIN_PATH + oldPlugin.getVersionedIdentifier().toString()); - } catch (URISyntaxException e) { + } catch (MalformedURLException e) { throw new IOException(e.getMessage()); } - File oldJarFile = new File(oldURI); + File oldJarFile = new File(oldURI.toExternalForm()); JarFile oldJar = new JarFile(oldJarFile); - URI newURI = null; + URL newURI = null; try { - newURI = new URI(consumer.getFeature().getSite().getURL().getPath() + + newURI = new URL(consumer.getFeature().getSite().getURL().getPath() + Site.DEFAULT_PLUGIN_PATH + newPlugin.getVersionedIdentifier().toString()); - } catch (URISyntaxException e) { + } catch (MalformedURLException e) { throw new IOException(e.getMessage()); } - File newJarFile = new File(newURI); + File newJarFile = new File(newURI.toExternalForm()); JarFile newJar = new JarFile(newJarFile); String tempFileName = oldURI + "-" + (new Date()).getTime(); //$NON-NLS-1$ @@ -85,7 +88,7 @@ newJar.close(); oldJar.close(); - newJarFile = new File(newURI); + newJarFile = new File(newURI.toExternalForm()); newJarFile.delete(); newJarFile.createNewFile(); @@ -93,25 +96,12 @@ copyFile(tempFile, newJarFile); } - static boolean useNioCopy = true; public static void copyFile(File src, File dst) throws IOException { - if (useNioCopy) { - try { - NioHelper.copyFile(src, dst); - return; - } catch (NoSuchMethodError e) { - // fall through - } catch (NoClassDefFoundError e) { - // fall through - } - useNioCopy = false; - } - - FileInputStream in=null; - FileOutputStream out=null; + InputStream in=null; + OutputStream out=null; try { - in = new FileInputStream(src); - out = new FileOutputStream(dst); + in = new BufferedInputStream(new FileInputStream(src)); + out = new BufferedOutputStream(new FileOutputStream(dst)); byte[] buffer = new byte[4096]; int len; while ((len=in.read(buffer)) != -1) { @@ -119,9 +109,15 @@ } } finally { if (in != null) - in.close(); + try { + in.close(); + } catch (IOException e) { + } if (out != null) - out.close(); + try { + out.close(); + } catch (IOException e) { + } } } Index: src/org/eclipse/update/core/Utilities.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/core/Utilities.java,v retrieving revision 1.54 diff -u -r1.54 Utilities.java --- src/org/eclipse/update/core/Utilities.java 28 Apr 2006 15:10:32 -0000 1.54 +++ src/org/eclipse/update/core/Utilities.java 4 May 2006 20:32:04 -0000 @@ -221,13 +221,19 @@ status = new Status(IStatus.ERROR, id, code, completeString.toString(), e); } CoreException ce = new CoreException(status); - if ( e instanceof CoreException) { + + if ( e instanceof FatalIOException) { + ce = new CoreExceptionWithRootCause(status); + ((CoreExceptionWithRootCause)ce).setRootException(e); + } + /* for when we move to 1.5 + if ( e instanceof CoreException) { ce.initCause(e.getCause()); } else { ce.initCause(e); } if (e != null) - ce.setStackTrace(e.getStackTrace()); + ce.setStackTrace(e.getStackTrace());*/ return ce; } Index: .settings/org.eclipse.jdt.core.prefs =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.update.core/.settings/org.eclipse.jdt.core.prefs,v retrieving revision 1.1 diff -u -r1.1 org.eclipse.jdt.core.prefs --- .settings/org.eclipse.jdt.core.prefs 3 May 2006 18:33:21 -0000 1.1 +++ .settings/org.eclipse.jdt.core.prefs 4 May 2006 20:32:04 -0000 @@ -1,5 +1,6 @@ -#Mon May 01 09:58:55 EDT 2006 +#Thu May 04 16:29:44 EDT 2006 eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 org.eclipse.jdt.core.compiler.compliance=1.4 org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning Index: src/org/eclipse/update/internal/mirror/MirrorSite.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/mirror/MirrorSite.java,v retrieving revision 1.17 diff -u -r1.17 MirrorSite.java --- src/org/eclipse/update/internal/mirror/MirrorSite.java 27 Apr 2006 17:11:21 -0000 1.17 +++ src/org/eclipse/update/internal/mirror/MirrorSite.java 4 May 2006 20:32:04 -0000 @@ -44,6 +44,7 @@ import org.eclipse.update.core.model.CategoryModel; import org.eclipse.update.core.model.SiteModelFactory; import org.eclipse.update.core.model.URLEntryModel; +import org.eclipse.update.internal.core.CoreExceptionWithRootCause; import org.eclipse.update.internal.core.FatalIOException; import org.eclipse.update.internal.core.ISiteContentConsumer; import org.eclipse.update.internal.core.UpdateCore; @@ -246,7 +247,10 @@ try { provider.getPluginEntryArchiveReferences(pluginsToInstall[i], null); } catch (CoreException ce) { - if ( ignoreNonPresentPlugins && (ce.getCause() != null) && (ce.getCause() instanceof FatalIOException) ) { + if ( ignoreNonPresentPlugins && + (ce instanceof CoreExceptionWithRootCause) && + (((CoreExceptionWithRootCause)ce).getRootException() != null) && + (((CoreExceptionWithRootCause)ce).getRootException() instanceof FatalIOException) ) { System.out.println("Could not mirror plug-in " + pluginsToInstall[i].getVersionedIdentifier().toString() + ". It does not exist on the given site"); //$NON-NLS-1$//$NON-NLS-2$ } else { throw ce; @@ -293,7 +297,10 @@ storePluginArchive(references[0]); addDownloadedPluginEntry(pluginsToInstall[i]); } catch (CoreException ce) { - if ( ignoreNonPresentPlugins && (ce.getCause() != null) && (ce.getCause() instanceof FatalIOException) ) { + if ( ignoreNonPresentPlugins && + (ce instanceof CoreExceptionWithRootCause) && + (((CoreExceptionWithRootCause)ce).getRootException() != null) && + (((CoreExceptionWithRootCause)ce).getRootException() instanceof FatalIOException) ) { System.out.println("Could not write plug-in " + pluginsToInstall[i].getVersionedIdentifier().toString() + ". It does not exist on the given site"); //$NON-NLS-1$ //$NON-NLS-2$ } else { //System.out.println("ignoreNonPresentPlugins:"+ignoreNonPresentPlugins); //$NON-NLS-1$ Index: .settings/org.eclipse.jdt.ui.prefs =================================================================== RCS file: .settings/org.eclipse.jdt.ui.prefs diff -N .settings/org.eclipse.jdt.ui.prefs --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ .settings/org.eclipse.jdt.ui.prefs 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,3 @@ +#Thu May 04 13:48:18 EDT 2006 +eclipse.preferences.version=1 +internal.default.compliance=default Index: src/org/eclipse/update/internal/core/CoreExceptionWithRootCause.java =================================================================== RCS file: src/org/eclipse/update/internal/core/CoreExceptionWithRootCause.java diff -N src/org/eclipse/update/internal/core/CoreExceptionWithRootCause.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/update/internal/core/CoreExceptionWithRootCause.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.update.internal.core; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; + +public class CoreExceptionWithRootCause extends CoreException { + + private static final long serialVersionUID = 6832993239926767403L; + + private Throwable e = null; + + public CoreExceptionWithRootCause(IStatus status) { + super(status); + } + + public void setRootException(Throwable e) { + this.e = e; + } + + public Throwable getRootException() { + return e; + } + + +}