| SiteManager.getSite(URL)throws CoreException | |
| String type = getTypeForprotocol(URL.getprotocol); | |
| try { | |
| if (type != null){ | |
| attemptCreationSite(type,URL); | |
| } else { | |
| attemptCreationSite("http",URL); | |
| } | |
| } catch (CoreException e){ | |
| throw new CoreException("Cannot create site",e.getMessage()); | |
| } | |
| SiteManager.attemptCreationSite(type,URL)throws CoreException | |
| try { | |
| createSite(type,URL); | |
| } catch (InvalidTypeException e){ | |
| try { | |
| createSite(e.getRealType(),URL); | |
| } catch (InvalidSiteExeption e){ | |
| throw new CoreException("Wrong site type"); | |
| } | |
| } | |
| SiteManager.createSite(type,URL) throws CoreExeption, InvalidSiteTypeException | |
| try { | |
| factory.createSite(url, forceCreation); | |
| } catch (IOException e) { | |
| // if the URL is pointing to either a file | |
| // or a directory, without reference | |
| if (url.getRef() != null) { | |
| // 4 nothing we can do | |
| throw newCoreException("Error accessing url:"+url.toExternalForm()+"\r\n"+e.getMessage(),e); | |
| } else if (url.getFile().endsWith("/")) { | |
| // 1 try to add site.xml | |
| try { | |
| url = new URL(url,Site.SITE_XML); | |
| } catch (MalformedURLException e1){ | |
| throw newCoreException("Cannot create URL:"+url.toExternalForm()+"+"+Site.SITE_XML,e1); | |
| } | |
| try { | |
| site = factory.createSite(url, forceCreation); | |
| } catch (ParsingException e1){ | |
| throw newCoreException("Error parsing URL:"+url.toExternalForm()+"\r\n"+e1.getMessage(),e1); | |
| } catch (IOException e1){ | |
| throw newCoreException("Error accessing url:"+url.toExternalForm()+"\r\n"+e1.getMessage(),e1); | |
| } | |
| } else if (url.getFile().endsWith(Site.SITE_XML)) { | |
| // 3 nothing we can do | |
| throw newCoreException("Error accessing url:"+url.toExternalForm()+"\r\n"+e.getMessage(),e); | |
| } else { | |
| // 2 try to add /site.xml | |
| try { | |
| url = new URL(url.getProtocol(),url.getHost(), url.getPort(), url.getFile()+"/"+Site.SITE_XML); | |
| } catch (MalformedURLException e1){ | |
| throw newCoreException("Cannot create URL:"+url.toExternalForm()+"+"+Site.SITE_XML,e1); | |
| } | |
| try { | |
| site = factory.createSite(url, forceCreation); | |
| } catch (ParsingException e1){ | |
| throw newCoreException("Error parsing URL:"+url.toExternalForm()+"\r\n"+e1.getMessage()+"\r\nPrevious Input/Output Error:"+e.getMessage(),e1); | |
| } catch (IOException e1){ | |
| throw newCoreException("Error accessing url:"+url.toExternalForm()+"\r\n"+e1.getMessage()+"\r\nPrevious Input/Output Error:"+e.getMessage(),e1); | |
| } | |
| } | |
| } catch (ParsingException e) { | |
| // if the URL is pointing to either a file | |
| // or a directory, without reference | |
| if (url.getRef() != null) { | |
| // 4 nothing we can do | |
| throw newCoreException("Error parsing URL:"+url.toExternalForm()+"\r\n"+e.getMessage(),e); | |
| } else if (url.getFile().endsWith("/")) { | |
| // 1 try to add site.xml | |
| try { | |
| url = new URL(url,Site.SITE_XML); | |
| } catch (MalformedURLException e1){ | |
| throw newCoreException("Cannot create URL:"+url.toExternalForm()+"+"+Site.SITE_XML,e1); | |
| } | |
| try { | |
| site = factory.createSite(url, forceCreation); | |
| } catch (ParsingException e1){ | |
| throw newCoreException("Error parsing URL:"+url.toExternalForm()+"\r\n"+e1.getMessage(),e1); | |
| } catch (IOException e1){ | |
| throw newCoreException("Error accessing url:"+url.toExternalForm()+"\r\n"+e1.getMessage(),e1); | |
| } | |
| } else if (url.getFile().endsWith(Site.SITE_XML)) { | |
| // 3 nothing we can do | |
| throw newCoreException("Error parsing URL:"+url.toExternalForm()+"\r\n"+e.getMessage(),e); | |
| } else { | |
| // 2 try to add /site.xml | |
| try { | |
| url = new URL(url.getProtocol(),url.getHost(), url.getPort(), url.getFile()+"/"+Site.SITE_XML); | |
| } catch (MalformedURLException e1){ | |
| throw newCoreException("Cannot create URL:"+url.toExternalForm()+"+"+Site.SITE_XML,e1); | |
| } | |
| try { | |
| site = factory.createSite(url, forceCreation); | |
| } catch (ParsingException e1){ | |
| throw newCoreException("Error parsing URL:"+url.toExternalForm()+"\r\n"+e1.getMessage()+"\r\nPrevious Parsing error:"+e.getMessage(),e1); | |
| } catch (IOException e1){ | |
| throw newCoreException("Error accessing url:"+url.toExternalForm()+"\r\n"+e1.getMessage()+"\r\nPrevious Parsing error:"+e.getMessage(),e1); | |