Example #1
0
 /**
  * Constructs a <tt>file:</tt> URI that represents this abstract pathname.
  *
  * <p>The exact form of the URI is system-dependent. If it can be determined that the file denoted
  * by this abstract pathname is a directory, then the resulting URI will end with a slash.
  *
  * <p>For a given abstract pathname <i>f</i>, it is guaranteed that
  *
  * <blockquote>
  *
  * <tt> new {@link #GeneralFile(java.net.URI) GeneralFile}
  * (</tt><i>&nbsp;f</i><tt>.toURI()).equals(</tt><i>&nbsp;f</i><tt>) </tt>
  *
  * </blockquote>
  *
  * so long as the original abstract pathname, the URI, and the new abstract pathname are all
  * created in (possibly different invocations of) the same Java virtual machine. However, this
  * relationship typically does not hold when a <tt>file:</tt> URI that is created in a virtual
  * machine on one operating system is converted into an abstract pathname in a virtual machine on
  * a different operating system.
  *
  * @return An absolute, hierarchical URI with a scheme equal to <tt>"file"</tt>, a path
  *     representing this abstract pathname, and undefined authority, query, and fragment
  *     components
  * @see #GeneralFile(java.net.URI)
  * @see java.net.URI
  * @see java.net.URI#toURL()
  */
 public URI toURI() {
   try {
     return new URI(toString());
   } catch (URISyntaxException e) {
     if (DEBUG > 0) e.printStackTrace();
   }
   return null;
 }
Example #2
0
  public static IFileArtifactRepository getAggregatedBundleRepository(
      IProvisioningAgent agent, IProfile profile, int repoFilter) {
    List<IFileArtifactRepository> bundleRepositories = new ArrayList<IFileArtifactRepository>();

    // we check for a shared bundle pool first as it should be preferred over the user bundle pool
    // in a shared install
    IArtifactRepositoryManager manager = getArtifactRepositoryManager(agent);
    if ((repoFilter & AGGREGATE_SHARED_CACHE) != 0) {
      String sharedCache = profile.getProperty(IProfile.PROP_SHARED_CACHE);
      if (sharedCache != null) {
        try {
          URI repoLocation = new File(sharedCache).toURI();
          IArtifactRepository repository = manager.loadRepository(repoLocation, null);
          if (repository != null
              && repository instanceof IFileArtifactRepository
              && !bundleRepositories.contains(repository))
            bundleRepositories.add((IFileArtifactRepository) repository);
        } catch (ProvisionException e) {
          // skip repository if it could not be read
        }
      }
    }

    if ((repoFilter & AGGREGATE_CACHE) != 0) {
      IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(agent, profile);
      if (bundlePool != null) bundleRepositories.add(bundlePool);
    }

    if ((repoFilter & AGGREGATE_CACHE_EXTENSIONS) != 0) {
      List<String> repos = getListProfileProperty(profile, CACHE_EXTENSIONS);
      for (String repo : repos) {
        try {
          URI repoLocation;
          try {
            repoLocation = new URI(repo);
          } catch (URISyntaxException e) {
            // in 1.0 we wrote unencoded URL strings, so try as an unencoded string
            repoLocation = URIUtil.fromString(repo);
          }
          IArtifactRepository repository = manager.loadRepository(repoLocation, null);
          if (repository != null
              && repository instanceof IFileArtifactRepository
              && !bundleRepositories.contains(repository))
            bundleRepositories.add((IFileArtifactRepository) repository);
        } catch (ProvisionException e) {
          // skip repositories that could not be read
        } catch (URISyntaxException e) {
          // unexpected, URLs should be pre-checked
          LogHelper.log(new Status(IStatus.ERROR, Activator.ID, e.getMessage(), e));
        }
      }
    }
    return new AggregatedBundleRepository(agent, bundleRepositories);
  }
  public static WMSCapabilities retrieve(URI uri) throws Exception {
    try {
      CapabilitiesRequest request = new CapabilitiesRequest(uri);

      return new WMSCapabilities(request);
    } catch (URISyntaxException e) {
      e.printStackTrace();
    } catch (MalformedURLException e) {
      e.printStackTrace();
    }

    return null;
  }
Example #4
0
 public static String convertUrlToBaseStringURI(URL url) {
   URI uri = null;
   try {
     uri = url.toURI();
   } catch (URISyntaxException e1) {
     e1.printStackTrace();
   }
   String scheme = uri.getScheme().toLowerCase();
   String host = uri.getHost().toLowerCase();
   int port = uri.getPort();
   if ((scheme.equals(HTTP_PROTOCOL) && port == HTTP_DEFAULT_PORT)
       || (scheme.equals(HTTPS_PROTOCOL) && port == HTTPS_DEFAULT_PORT)) {
     port = -1;
   }
   URI baseUri = null;
   try {
     baseUri = new URI(scheme, null, host, port, uri.getPath(), null, null);
   } catch (URISyntaxException e) {
     e.printStackTrace();
   }
   return baseUri.toString();
 }