1 11 package org.eclipse.update.standalone; 12 import java.io.*; 13 import java.net.*; 14 15 import org.eclipse.core.runtime.*; 16 import org.eclipse.update.configuration.*; 17 import org.eclipse.update.core.*; 18 import org.eclipse.update.internal.core.*; 19 import org.eclipse.update.operations.*; 20 21 31 public class AddSiteCommand extends ScriptedCommand { 32 private ISite site; 33 private File sitePath; 34 35 38 public AddSiteCommand(String fromSite) throws Exception { 39 try { 40 if (fromSite != null) { 41 sitePath = new File(fromSite); 42 if (!sitePath.exists()) 43 throw new Exception (Messages.Standalone_noSite + fromSite); 44 45 URL fromSiteURL = sitePath.toURL(); 46 site = SiteManager.getSite(fromSiteURL, null); 47 if (site == null) { 48 throw new Exception (Messages.Standalone_noSite + fromSite); 49 } 50 IConfiguredSite csite = site.getCurrentConfiguredSite(); 51 if (csite != null) 52 throw new Exception (Messages.Standalone_siteConfigured + fromSite); 53 } else { 54 throw new Exception (Messages.Standalone_noSite3 ); 55 } 56 } catch (Exception e) { 57 throw e; 58 } 59 } 60 61 63 public boolean run(IProgressMonitor monitor) { 64 IStatus status = OperationsManager.getValidator().validatePlatformConfigValid(); 66 if (status != null) { 67 UpdateCore.log(status); 68 return false; 69 } 70 71 if (site == null) 72 return false; 73 74 try { 75 IConfiguredSite csite = getConfiguration().createConfiguredSite(sitePath); 76 getConfiguration().addConfiguredSite(csite); 77 getConfiguration().getConfiguredSites(); 79 SiteManager.getLocalSite().save(); 80 return true; 81 } catch (CoreException e) { 82 UpdateCore.log(e); 83 return false; 84 } 85 } 86 } 87 | Popular Tags |