View | Details | Raw Unified | Return to bug 139056 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/update/internal/core/NioHelper.java (-41 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.update.internal.core;
13
import java.io.File;
14
import java.io.FileInputStream;
15
import java.io.FileOutputStream;
16
import java.io.IOException;
17
import java.nio.channels.FileChannel;
18
19
20
public class NioHelper {
21
	// This method must be in a seperate class file otherwise a NIO class not found error
22
	//  will be thrown loading the calling class.  We put it in it's own class so the
23
	//  caller can catch the error/exception.
24
	static void copyFile(File src, File dst) throws IOException {
25
		FileChannel in = null;
26
		FileChannel out = null; 
27
		
28
		try {
29
			in = new FileInputStream(src).getChannel();
30
			out = new FileOutputStream(dst).getChannel();
31
			in.transferTo( 0, in.size(), out);
32
		} finally {
33
			if (in != null)
34
				in.close();
35
			if (out != null) 
36
				out.close();
37
		}
38
	}
39
40
41
}
(-)src/org/eclipse/update/internal/core/JarDeltaInstallHandler.java (-31 / +27 lines)
Lines 11-23 Link Here
11
11
12
package org.eclipse.update.internal.core;
12
package org.eclipse.update.internal.core;
13
13
14
import java.io.BufferedInputStream;
15
import java.io.BufferedOutputStream;
14
import java.io.File;
16
import java.io.File;
15
import java.io.FileInputStream;
17
import java.io.FileInputStream;
16
import java.io.FileOutputStream;
18
import java.io.FileOutputStream;
17
import java.io.IOException;
19
import java.io.IOException;
18
import java.io.InputStream;
20
import java.io.InputStream;
19
import java.net.URI;
21
import java.io.OutputStream;
20
import java.net.URISyntaxException;
22
import java.net.MalformedURLException;
23
import java.net.URL;
21
import java.util.Date;
24
import java.util.Date;
22
import java.util.Enumeration;
25
import java.util.Enumeration;
23
import java.util.jar.JarFile;
26
import java.util.jar.JarFile;
Lines 48-74 Link Here
48
			
51
			
49
			ContentReference[] oldReferences = oldFeature.getFeatureContentProvider().getPluginEntryContentReferences(oldPlugin, null);
52
			ContentReference[] oldReferences = oldFeature.getFeatureContentProvider().getPluginEntryContentReferences(oldPlugin, null);
50
			ContentReference[] newReferences = feature.getFeatureContentProvider().getPluginEntryContentReferences(newPlugin, null);
53
			ContentReference[] newReferences = feature.getFeatureContentProvider().getPluginEntryContentReferences(newPlugin, null);
51
			
54
52
			URI oldURI = null;
55
			URL oldURI = null;
53
			try {
56
			try {
54
				oldURI = new URI(consumer.getFeature().getSite().getURL().getPath() + 
57
				oldURI = new URL(consumer.getFeature().getSite().getURL().getPath() + 
55
									 Site.DEFAULT_PLUGIN_PATH + 
58
									 Site.DEFAULT_PLUGIN_PATH + 
56
									 oldPlugin.getVersionedIdentifier().toString());
59
									 oldPlugin.getVersionedIdentifier().toString());
57
			} catch (URISyntaxException e) {
60
			} catch (MalformedURLException e) {
58
				throw new IOException(e.getMessage());
61
				throw new IOException(e.getMessage());
59
			}
62
			}
60
			File oldJarFile = new File(oldURI);
63
			File oldJarFile = new File(oldURI.toExternalForm());
61
			JarFile oldJar = new JarFile(oldJarFile);
64
			JarFile oldJar = new JarFile(oldJarFile);
62
			
65
			
63
			URI newURI = null;
66
			URL newURI = null;
64
			try {
67
			try {
65
				newURI = new URI(consumer.getFeature().getSite().getURL().getPath() + 
68
				newURI = new URL(consumer.getFeature().getSite().getURL().getPath() + 
66
								 Site.DEFAULT_PLUGIN_PATH + 
69
								 Site.DEFAULT_PLUGIN_PATH + 
67
								 newPlugin.getVersionedIdentifier().toString());
70
								 newPlugin.getVersionedIdentifier().toString());
68
			} catch (URISyntaxException e) {
71
			} catch (MalformedURLException e) {
69
				throw new IOException(e.getMessage());
72
				throw new IOException(e.getMessage());
70
			}
73
			}
71
			File newJarFile = new File(newURI);
74
			File newJarFile = new File(newURI.toExternalForm());
72
			JarFile newJar = new JarFile(newJarFile);
75
			JarFile newJar = new JarFile(newJarFile);
73
76
74
			String tempFileName = oldURI + "-" + (new Date()).getTime(); //$NON-NLS-1$
77
			String tempFileName = oldURI + "-" + (new Date()).getTime(); //$NON-NLS-1$
Lines 85-91 Link Here
85
			newJar.close();
88
			newJar.close();
86
			oldJar.close();
89
			oldJar.close();
87
			
90
			
88
			newJarFile = new File(newURI);
91
			newJarFile = new File(newURI.toExternalForm());
89
			newJarFile.delete();
92
			newJarFile.delete();
90
			
93
			
91
			newJarFile.createNewFile();
94
			newJarFile.createNewFile();
Lines 93-117 Link Here
93
			copyFile(tempFile, newJarFile);
96
			copyFile(tempFile, newJarFile);
94
	}
97
	}
95
	
98
	
96
	static boolean useNioCopy = true;
97
	public static void copyFile(File src, File dst) throws IOException {
99
	public static void copyFile(File src, File dst) throws IOException {
98
		if (useNioCopy) {
100
		InputStream in=null;
99
			try {
101
		OutputStream out=null;
100
				NioHelper.copyFile(src, dst);
101
				return;
102
			} catch (NoSuchMethodError e) {
103
				// fall through
104
			} catch (NoClassDefFoundError e) {
105
				// fall through
106
			}
107
			useNioCopy = false;
108
		}
109
		
110
		FileInputStream in=null;
111
		FileOutputStream out=null;
112
		try {
102
		try {
113
			in = new FileInputStream(src);
103
			in = new BufferedInputStream(new FileInputStream(src));
114
			out = new FileOutputStream(dst);		
104
			out = new BufferedOutputStream(new FileOutputStream(dst));		
115
			byte[] buffer = new byte[4096];
105
			byte[] buffer = new byte[4096];
116
			int len;
106
			int len;
117
			while ((len=in.read(buffer)) != -1) {
107
			while ((len=in.read(buffer)) != -1) {
Lines 119-127 Link Here
119
			}
109
			}
120
		} finally {
110
		} finally {
121
			if (in != null)
111
			if (in != null)
122
				in.close();
112
				try {
113
					in.close();
114
				} catch (IOException e) {
115
				}
123
			if (out != null)
116
			if (out != null)
124
				out.close();
117
				try {
118
					out.close();
119
				} catch (IOException e) {
120
				}
125
		}
121
		}
126
	}
122
	}
127
123
(-)src/org/eclipse/update/core/Utilities.java (-2 / +8 lines)
Lines 221-233 Link Here
221
			status = new Status(IStatus.ERROR, id, code, completeString.toString(), e);
221
			status = new Status(IStatus.ERROR, id, code, completeString.toString(), e);
222
		}
222
		}
223
		CoreException ce = new CoreException(status);
223
		CoreException ce = new CoreException(status);
224
		if ( e instanceof CoreException) {
224
		
225
		if ( e instanceof FatalIOException) {
226
			ce = new CoreExceptionWithRootCause(status);
227
			((CoreExceptionWithRootCause)ce).setRootException(e);
228
		}
229
		/* for when we move to 1.5
230
		 if ( e instanceof CoreException) {
225
			ce.initCause(e.getCause());
231
			ce.initCause(e.getCause());
226
		} else {
232
		} else {
227
			ce.initCause(e);
233
			ce.initCause(e);
228
		}
234
		}
229
		if (e != null)
235
		if (e != null)
230
			ce.setStackTrace(e.getStackTrace());
236
			ce.setStackTrace(e.getStackTrace());*/
231
		return ce; 
237
		return ce; 
232
	}
238
	}
233
239
(-).settings/org.eclipse.jdt.core.prefs (-1 / +2 lines)
Lines 1-5 Link Here
1
#Mon May 01 09:58:55 EDT 2006
1
#Thu May 04 16:29:44 EDT 2006
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
4
org.eclipse.jdt.core.compiler.compliance=1.4
5
org.eclipse.jdt.core.compiler.compliance=1.4
5
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
(-)src/org/eclipse/update/internal/mirror/MirrorSite.java (-2 / +9 lines)
Lines 44-49 Link Here
44
import org.eclipse.update.core.model.CategoryModel;
44
import org.eclipse.update.core.model.CategoryModel;
45
import org.eclipse.update.core.model.SiteModelFactory;
45
import org.eclipse.update.core.model.SiteModelFactory;
46
import org.eclipse.update.core.model.URLEntryModel;
46
import org.eclipse.update.core.model.URLEntryModel;
47
import org.eclipse.update.internal.core.CoreExceptionWithRootCause;
47
import org.eclipse.update.internal.core.FatalIOException;
48
import org.eclipse.update.internal.core.FatalIOException;
48
import org.eclipse.update.internal.core.ISiteContentConsumer;
49
import org.eclipse.update.internal.core.ISiteContentConsumer;
49
import org.eclipse.update.internal.core.UpdateCore;
50
import org.eclipse.update.internal.core.UpdateCore;
Lines 246-252 Link Here
246
			try {
247
			try {
247
				provider.getPluginEntryArchiveReferences(pluginsToInstall[i], null);
248
				provider.getPluginEntryArchiveReferences(pluginsToInstall[i], null);
248
			} catch (CoreException ce) {
249
			} catch (CoreException ce) {
249
				if ( ignoreNonPresentPlugins && (ce.getCause() != null) && (ce.getCause() instanceof FatalIOException) ) {
250
				if ( ignoreNonPresentPlugins && 
251
						(ce instanceof CoreExceptionWithRootCause) &&
252
						(((CoreExceptionWithRootCause)ce).getRootException() != null) && 
253
						(((CoreExceptionWithRootCause)ce).getRootException() instanceof FatalIOException) ) {
250
					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$
254
					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$
251
				} else {
255
				} else {
252
					throw ce;
256
					throw ce;
Lines 293-299 Link Here
293
				storePluginArchive(references[0]);
297
				storePluginArchive(references[0]);
294
				addDownloadedPluginEntry(pluginsToInstall[i]);
298
				addDownloadedPluginEntry(pluginsToInstall[i]);
295
			} catch (CoreException ce) {
299
			} catch (CoreException ce) {
296
				if ( ignoreNonPresentPlugins && (ce.getCause() != null) && (ce.getCause() instanceof FatalIOException) ) {
300
				if ( ignoreNonPresentPlugins && 
301
						(ce instanceof CoreExceptionWithRootCause) &&
302
						(((CoreExceptionWithRootCause)ce).getRootException() != null) && 
303
						(((CoreExceptionWithRootCause)ce).getRootException() instanceof FatalIOException) ) {
297
					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$
304
					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$
298
				} else {
305
				} else {
299
					//System.out.println("ignoreNonPresentPlugins:"+ignoreNonPresentPlugins); //$NON-NLS-1$
306
					//System.out.println("ignoreNonPresentPlugins:"+ignoreNonPresentPlugins); //$NON-NLS-1$
(-).settings/org.eclipse.jdt.ui.prefs (+3 lines)
Added Link Here
1
#Thu May 04 13:48:18 EDT 2006
2
eclipse.preferences.version=1
3
internal.default.compliance=default
(-)src/org/eclipse/update/internal/core/CoreExceptionWithRootCause.java (+35 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.update.internal.core;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.core.runtime.IStatus;
15
16
public class CoreExceptionWithRootCause extends CoreException {
17
18
	private static final long serialVersionUID = 6832993239926767403L;
19
	
20
	private Throwable e = null;
21
	
22
	public CoreExceptionWithRootCause(IStatus status) {
23
		super(status);
24
	}
25
26
	public void setRootException(Throwable e) {
27
		this.e = e;	
28
	}
29
30
	public Throwable getRootException() {
31
		return e;
32
	}
33
34
	
35
}

Return to bug 139056