private static String fallback(final String rawLocation) { if (rawLocation.startsWith(MVN_PREFIX)) { try { final String repo1Url = quickMvnUrl(rawLocation.substring(MVN_PREFIX.length()).replace(":", "/")); final String real = realLocation(repo1Url); return real; } catch (final MalformedURLException e1) { Logger.getLogger(ProvisioningUtil.class.getName()).severe("Can't find " + rawLocation); } } else { // try url try { final File file = cacheFile(lastPart(rawLocation)); final URL url = new URL(rawLocation); InputStream is = null; try { is = new BufferedInputStream(url.openStream()); IO.copy(is, file); return file.getAbsolutePath(); } finally { IO.close(is); } } catch (final Exception e1) { // no-op } } // if it was not an url that's just a file path return rawLocation; }
/** * * @param rawLocation * @return */ public static String realLocation(final String rawLocation) { if (hasHttpOrHttpsPrefix(rawLocation)) { final File file = cacheFile(lastPart(rawLocation)); if (file.exists()) { return file.getAbsolutePath(); } String path = null; try { path = copyTryingProxies(new URI(rawLocation), file); } catch (final Exception e1) { // ignored } if (path != null) { return path; } } try { // full maven resolution final Class<?> clazz = ProvisioningUtil.class.getClassLoader().loadClass("org.apache.openejb.resolver.Resolver"); final LocationResolver instance = (LocationResolver) clazz.newInstance(); return instance.resolve(rawLocation); } catch (final Throwable e) { // NoClassDefFoundError is not an exception return fallback(rawLocation); } }