@JsonIgnore public boolean isCached() throws IllegalStateException { return this.getAbsM2Path().toFile().exists(); }
private Path downloadArtifactFile(Artifact a) throws Exception{ Path p = null; // Create the dir Path artifact_dir = a.getAbsM2Path().getParent(); if(!artifact_dir.toFile().exists()) Files.createDirectories(artifact_dir); final ServiceLoader<RepositoryWrapper> loader = ServiceLoader.load(RepositoryWrapper.class); for(RepositoryWrapper dv: loader) { if(dv.isConfigured() && (dv.getSupportedLanguages().contains(a.getProgrammingLanguage()))) { try{ p = dv.downloadArtifact(a); if(p!=null) break; }catch(NotImplementedException e){ }catch(UnsupportedOperationException e){ } } } if(p==null) throw new FileNotFoundException(); return p; }
@Override public Path downloadArtifact(Artifact _doc) throws Exception { final String url = MAVEN_CENTRAL_REPO; final StringBuilder b = new StringBuilder(); b.append(url); b.append(_doc.getLibId().getMvnGroup().replace('.', '/')).append("/"); b.append(_doc.getLibId().getArtifact()).append("/"); b.append(_doc.getLibId().getVersion()).append("/"); b.append(_doc.getM2Filename()); // Make the query final RestTemplate rest_template = new RestTemplate(); Path result = null; try{ rest_template.execute(b.toString(), HttpMethod.GET, new DefaultRequestCallback(), new FileResponseExtractor(_doc, _doc.getAbsM2Path())); result = _doc.getAbsM2Path(); } catch(HttpClientErrorException e) { MavenCentralWrapper.log.error(_doc + " not available at [" +b.toString()+ "]"); } return result; }
log.debug(a.toString() + " available in local m2 repo: [" + a.getAbsM2Path() + "]"); p = a.getAbsM2Path();
} else { try{ rest_template.execute(serviceUrl, HttpMethod.GET, new DefaultRequestCallback(), new FileResponseExtractor(a, a.getAbsM2Path()),params); result = a.getAbsM2Path();
rest_template.execute(downloadUrl, HttpMethod.GET, new DefaultRequestCallback(), new FileResponseExtractor(a, a.getAbsM2Path())); result = a.getAbsM2Path();