/** * Find the plugin artifact in the local .m2 directory. * @param m2Dir the maven m2 directory * @param coordinates the coordinates * @return the M2 path */ public static File getM2Path(File m2Dir, PluginCoordinates coordinates) { String artifactSubPath = getMavenPath(coordinates); return new File(m2Dir, artifactSubPath); }
/** * Find the plugin artifact in the local .m2 directory. * @param m2Dir the maven m2 directory * @param coordinates the coordinates * @return the M2 path */ public static File getM2Path(File m2Dir, PluginCoordinates coordinates) { String artifactSubPath = getMavenPath(coordinates); return new File(m2Dir, artifactSubPath); }
/** * @see io.apiman.manager.api.core.plugin.AbstractPluginRegistry#downloadPlugin(java.io.File, io.apiman.common.plugin.PluginCoordinates) */ @Override protected void downloadPlugin(File pluginFile, PluginCoordinates coordinates) { String testM2Path = System.getProperty("apiman.test.m2-path"); //$NON-NLS-1$ if (testM2Path == null) { return; } File testM2Dir = new File(testM2Path).getAbsoluteFile(); File pluginArtifactFile = new File(testM2Dir, PluginUtils.getMavenPath(coordinates)); if (!pluginArtifactFile.isFile()) { return; } try { FileUtils.copyFile(pluginArtifactFile, pluginFile); } catch (IOException e) { pluginArtifactFile.delete(); } }
/** * Tries to download the plugin from the given remote maven repository. */ protected void downloadFromMavenRepo(PluginCoordinates coordinates, URI mavenRepoUrl, IAsyncResultHandler<File> handler) { String artifactSubPath = PluginUtils.getMavenPath(coordinates); try { File tempArtifactFile = File.createTempFile("_plugin", "dwn"); //$NON-NLS-1$ //$NON-NLS-2$ URL artifactUrl = new URL(mavenRepoUrl.toURL(), artifactSubPath); downloadArtifactTo(artifactUrl, tempArtifactFile, handler); } catch (Exception e) { handler.handle(AsyncResultImpl.<File>create(e)); } }
/** * Tries to download the plugin from the given remote maven repository. */ protected boolean downloadFromMavenRepo(File pluginFile, PluginCoordinates coordinates, URI mavenRepoUrl) { String artifactSubPath = PluginUtils.getMavenPath(coordinates); InputStream istream = null; OutputStream ostream = null; try { URL artifactUrl = new URL(mavenRepoUrl.toURL(), artifactSubPath); URLConnection connection = artifactUrl.openConnection(); connection.connect(); if (connection instanceof HttpURLConnection) { HttpURLConnection httpConnection = (HttpURLConnection) connection; if (httpConnection.getResponseCode() != 200) { throw new IOException(); } } istream = connection.getInputStream(); ostream = new FileOutputStream(pluginFile); IOUtils.copy(istream, ostream); ostream.flush(); return true; } catch (Exception e) { return false; } finally { IOUtils.closeQuietly(istream); IOUtils.closeQuietly(ostream); } }
/** * Tries to download the plugin from the given remote maven repository. */ protected void downloadFromMavenRepo(PluginCoordinates coordinates, URI mavenRepoUrl, IAsyncResultHandler<File> handler) { String artifactSubPath = PluginUtils.getMavenPath(coordinates); try { File tempArtifactFile = File.createTempFile("_plugin", "dwn"); //$NON-NLS-1$ //$NON-NLS-2$ URL artifactUrl = new URL(mavenRepoUrl.toURL(), artifactSubPath); downloadArtifactTo(artifactUrl, tempArtifactFile, handler); } catch (Exception e) { handler.handle(AsyncResultImpl.<File>create(e)); } }