1 11 package org.eclipse.update.core; 12 13 import java.net.*; 14 15 import org.eclipse.core.runtime.*; 16 import org.eclipse.osgi.util.NLS; 17 import org.eclipse.update.internal.core.Messages; 18 import org.eclipse.update.internal.core.UpdateCore; 19 20 29 public abstract class SiteContentProvider implements ISiteContentProvider { 30 31 private URL base; 32 private ISite site; 33 34 37 public SiteContentProvider(URL url) { 38 super(); 39 this.base = url; 40 } 41 42 48 public URL getURL() { 49 return base; 50 } 51 52 58 private URL getArchiveReference1(String archiveID) throws CoreException { 59 try { 60 return new URL(getURL(), archiveID); 61 } catch (MalformedURLException e) { 62 throw Utilities.newCoreException( 63 NLS.bind(Messages.SiteContentProvider_ErrorCreatingURLForArchiveID, (new String [] { archiveID, getURL().toExternalForm() })), 64 e); 65 } 66 } 67 68 74 public ISite getSite() { 75 return site; 76 } 77 78 84 public void setSite(ISite site) { 85 this.site = site; 86 } 87 88 public URL getArchiveReference(String archiveId) throws CoreException { 89 URL contentURL = null; 90 91 contentURL = getArchiveURLfor(archiveId); 92 if (contentURL==null) { 95 return getArchiveReference1(archiveId); 96 } 97 98 return contentURL; 99 } 100 101 107 private URL getArchiveURLfor(String archiveId) { 108 URL result = null; 109 boolean found = false; 110 111 IArchiveReference[] siteArchives = getSite().getArchives(); 112 if (siteArchives.length > 0) { 113 for (int i = 0; i < siteArchives.length && !found; i++) { 114 if (UpdateCore.DEBUG && UpdateCore.DEBUG_SHOW_INSTALL) 115 UpdateCore.debug("GetArchiveURL for:"+archiveId+" compare to "+siteArchives[i].getPath()); if (archiveId.trim().equalsIgnoreCase(siteArchives[i].getPath())) { 117 result = siteArchives[i].getURL(); 118 found = true; 119 break; 120 } 121 } 122 } 123 return result; 124 } 125 } 126 | Popular Tags |