@Override protected File download(Exception previousException) throws Exception { return resolver.resolve(url, previousException); }
@Override public RetryChance isRetryableException(Exception exception) { return fallback.isRetryableException(exception); }
@Override public void upload(String groupId, String artifactId, String classifier, String extension, String version, File artifact) throws IOException { fallback.upload(groupId, artifactId, classifier, extension, version, artifact); }
private static void createAndDeployArtifact() throws IOException { // create jar file File tempFile = File.createTempFile("comps-api-tests", ".jar"); try { // adds a dep.txt entry LOG.debug("created temp artifact jar" + tempFile.getAbsolutePath()); ZipOutputStream out = new ZipOutputStream(new FileOutputStream(tempFile)); String depsEntryPath = "META-INF/maven/" + TEST_GROUPID + "/" + TEST_ARTEFACTID + "/dependencies.txt"; ZipEntry e = new ZipEntry(depsEntryPath); out.putNextEntry(e); InputStream depTxtStream = DependenciesReaderTest.class.getResourceAsStream("/" + depsEntryPath); byte[] data = IOUtils.toByteArray(depTxtStream); out.write(data, 0, data.length); out.closeEntry(); out.close(); // deploy it MavenResolver mavenResolver = MavenResolvers.createMavenResolver(null, "foo"); mavenResolver.upload(TEST_GROUPID, TEST_ARTEFACTID, "jar", "jar", TEST_VERSION, tempFile); tempMavenFilePath = mavenResolver.resolve(TEST_GROUPID, TEST_ARTEFACTID, "jar", "jar", TEST_VERSION) .getAbsolutePath(); LOG.debug("artifact deployed:" + tempMavenFilePath); } finally { // remove it tempFile.delete(); } }
@Override public File resolveMetadata(String groupId, String artifactId, String type, String version, Exception previousException) throws IOException { return fallback.resolveMetadata(groupId, artifactId, type, version, previousException); }
@Override public void close() throws IOException { fallback.close(); }
@Override public File resolveMetadata(String groupId, String artifactId, String type, String version) throws IOException { return fallback.resolveMetadata(groupId, artifactId, type, version); }
@Override public void close() throws IOException { fallback.close(); }
private boolean canResolveAllFeatureUris(List<Repository> repositories) { for (Repository repository : repositories) { for (URI featureUri : repository.getFeatureUris()) { try { if (m_mavenResolver.resolve(featureUri.toString()) == null) { return false; } } catch (Exception e) { return false; } } } return true; }
@Override public RetryChance isRetryableException(Exception exception) { return fallback.isRetryableException(exception); }
@Override public void upload(String groupId, String artifactId, String classifier, String extension, String version, File artifact) throws IOException { fallback.upload(groupId, artifactId, classifier, extension, version, artifact); }
@Override public File resolveMetadata(String groupId, String artifactId, String type, String version) throws IOException { return fallback.resolveMetadata(groupId, artifactId, type, version); }
private boolean canResolveAllFeatureUris(List<Repository> repositories) { for (Repository repository : repositories) { for (URI featureUri : repository.getFeatureUris()) { try { if (m_mavenResolver.resolve(featureUri.toString()) == null) { return false; } } catch (Exception e) { return false; } } } return true; }
/** * Maven artifact may be looked up in several repositories. Only if exception for <strong>each</strong> * repository is not retryable, we won't retry. * @param e * @return */ @Override protected Retry isRetryable(IOException e) { // convert pax-url-aether "retry" to features.core "retry" concept switch (resolver.isRetryableException(e)) { case NEVER: return Retry.NO_RETRY; case LOW: case HIGH: // no need to repeat many times return Retry.QUICK_RETRY; case UNKNOWN: default: return Retry.DEFAULT_RETRY; } }
@Override public File resolveMetadata(String groupId, String artifactId, String type, String version, Exception previousException) throws IOException { return fallback.resolveMetadata(groupId, artifactId, type, version, previousException); }
@Override public File resolve(String groupId, String artifactId, String classifier, String extension, String version) throws IOException { File file = reactor.findArtifact(new DefaultArtifact(groupId, artifactId, classifier, extension, version)); return file == null ? fallback.resolve(String.format("mvn:%s/%s/%s/%s/%s", groupId, artifactId, version, extension, classifier)) : file; }
@Override public File resolve(String groupId, String artifactId, String classifier, String extension, String version) throws IOException { File file = reactor.findArtifact(new DefaultArtifact(groupId, artifactId, classifier, extension, version)); return file == null ? fallback.resolve(String.format("mvn:%s/%s/%s/%s/%s", groupId, artifactId, version, extension, classifier)) : file; }
@Override public File resolve(String groupId, String artifactId, String classifier, String extension, String version, Exception previousException) throws IOException { File file = reactor.findArtifact(new DefaultArtifact(groupId, artifactId, classifier, extension, version)); return file == null ? fallback.resolve(String.format("mvn:%s/%s/%s/%s/%s", groupId, artifactId, version, extension, classifier), previousException) : file; }
@Override public File resolve(String groupId, String artifactId, String classifier, String extension, String version, Exception previousException) throws IOException { File file = reactor.findArtifact(new DefaultArtifact(groupId, artifactId, classifier, extension, version)); return file == null ? fallback.resolve(String.format("mvn:%s/%s/%s/%s/%s", groupId, artifactId, version, extension, classifier), previousException) : file; }
private void unzipMvnArtifact(String aConfigtMvnUrlStr, String aConfigFolderPath) throws IOException { RuntimeUtil.registerMavenUrlHandler(); MavenResolver mavenResolver = MavenResolvers.createMavenResolver(null, ServiceConstants.PID); File artifactToUnzip = mavenResolver.resolve(aConfigtMvnUrlStr); try (ZipFile zipFile = new ZipFile(artifactToUnzip)) { try { Enumeration<? extends ZipEntry> entries = zipFile.entries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); File entryDestination = new File(aConfigFolderPath, entry.getName()); if (entry.isDirectory()) { entryDestination.mkdirs(); } else { entryDestination.getParentFile().mkdirs(); InputStream in = zipFile.getInputStream(entry); OutputStream out = new FileOutputStream(entryDestination); IOUtils.copy(in, out); IOUtils.closeQuietly(in); out.close(); } } } finally { zipFile.close(); } } }