1 11 package org.eclipse.update.internal.core; 12 import java.io.*; 13 import java.net.*; 14 15 import org.eclipse.core.runtime.*; 16 import org.eclipse.osgi.util.NLS; 17 import org.eclipse.update.core.*; 18 import org.eclipse.update.core.model.*; 19 20 23 public class FeaturePackagedFactory extends BaseFeatureFactory { 24 25 28 public IFeature createFeature(URL url,ISite site, IProgressMonitor monitor) throws CoreException { 29 Feature feature = null; 30 InputStream featureStream = null; 31 if (monitor == null) 32 monitor = new NullProgressMonitor(); 33 monitor.beginTask(null,2); 34 monitor.worked(1); 35 36 37 try { 38 IFeatureContentProvider contentProvider = new FeaturePackagedContentProvider(url, site); 39 ContentReference manifest = contentProvider.getFeatureManifestReference(null); 40 featureStream = manifest.getInputStream(); 41 feature = (Feature)parseFeature(featureStream); 42 monitor.worked(1); 43 44 if (feature.getUpdateSiteEntry()==null){ 47 URLEntryModel entryModel = createURLEntryModel(); 48 URL siteUrl = site.getURL(); 49 if (siteUrl!=null){ 50 entryModel.setURLString(siteUrl.toExternalForm()); 51 entryModel.resolve(siteUrl,null); 52 feature.setUpdateSiteEntryModel(entryModel); 53 } 54 } 55 feature.setFeatureContentProvider(contentProvider); 56 feature.setSite(site); 57 URL baseUrl = null; 58 try { 59 baseUrl = new URL(manifest.asURL(),"."); } catch(MalformedURLException e) { 61 } 62 feature.resolve(baseUrl, baseUrl); 63 feature.markReadOnly(); 64 } catch (CoreException e){ 65 throw e; 66 } catch (Exception e) { 67 e.printStackTrace(); 68 throw Utilities.newCoreException(NLS.bind(Messages.FeatureFactory_CreatingError, (new String [] { url.toExternalForm() })), e); 69 }finally { 70 try { 71 if (featureStream!=null) 72 featureStream.close(); 73 } catch (IOException e) { 74 } 75 } 76 return feature; 77 } 78 79 public IncludedFeatureReferenceModel createIncludedFeatureReferenceModel() { 80 return new UpdateSiteIncludedFeatureReference(); 81 } 82 } 83 | Popular Tags |