/** * Returns a {@link LibraryId} corresponding to this {@link ResponseDoc}. * @param _libid * @return */ public Artifact toArtifact() { Artifact r = new Artifact(g,a,v); r.setTimestamp(timestamp); r.setProgrammingLanguage(ProgrammingLanguage.JAVA); return r; }
a.setClassifier(classifier.equals("")?null:classifier); a.setPackaging(packaging); a.setProgrammingLanguage(lang);
Artifact a = new Artifact(mvnGroup,artifact,version); a.setPackaging(packaging); a.setProgrammingLanguage(lang);
a.setClassifier((ClassDownloader.Format.JAVA==_format?"sources":null) ); a.setPackaging( "jar" ); a.setProgrammingLanguage(ProgrammingLanguage.JAVA);
@Override public Set<Artifact> getAllArtifactVersions(String group, String artifact, String classifier, String packaging) throws Exception { Set<Artifact> result = new TreeSet<Artifact>(); final PypiResponse response = this.searchInPypi(artifact,null); if(response!=null){ for(String k:response.getReleases().keySet()){ //the inner loop only creates artifacts if the key (e.g., "1.0.1") contains something // and it creates an artifact with the timestamp of the first element found // TODO: should we pick wheel, tar.gz, or what? for(PypiRelease release : response.getReleases().get(k)){ Artifact a = new Artifact(artifact,artifact,k); a.setProgrammingLanguage(ProgrammingLanguage.PY); if(release.getUpload_time()!=null && !release.getUpload_time().equals("")){ String upload_time = release.getUpload_time().replace("T"," "); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); Date parsedDate = dateFormat.parse(upload_time); a.setTimestamp(parsedDate.getTime()); } result.add(a); break; } } } return result; }
doc.setClassifier(d.getC()); doc.setTimestamp(d.getTimestamp()); doc.setProgrammingLanguage(ProgrammingLanguage.JAVA); log.info("Found artifact " + versions.first() + " for SHA1 [" + _sha1 + "]");
if(response!=null){ result = new Artifact(response.getGroupId(),response.getArtifactId(),response.getVersion()); result.setProgrammingLanguage(ProgrammingLanguage.JAVA); ResponseEntity<NexusArtifactInfoResourceResponse> responseForTimestamp = null;
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); result.setTimestamp(dateFormat.parse(upload_time).getTime()); result.setProgrammingLanguage(ProgrammingLanguage.PY); break; result.setTimestamp(dateFormat.parse(upload_time).getTime()); result.setProgrammingLanguage(ProgrammingLanguage.PY); break;
Artifact a = new Artifact(mvnGroup,artifact,version); a.setPackaging(pack); a.setProgrammingLanguage(lang);
@Override public Artifact getArtifactForDigest(String digest) throws InterruptedException { //currently it only returns the lib id, to check whether package classifier and timestamp can be obtained (if needed) NexusSearchNGResponse nexusResp = this.searchInNexus(null, null, null, null, null, digest.toLowerCase()); Artifact result = null; if(nexusResp.getData()!=null && nexusResp.getData().getArtifactList()!=null && nexusResp.getData().getArtifactList().size()==1){ result = new Artifact(nexusResp.getData().getArtifactList().get(0).getGroupId(), nexusResp.getData().getArtifactList().get(0).getArtifactId(), nexusResp.getData().getArtifactList().get(0).getVersion()); result.setProgrammingLanguage(ProgrammingLanguage.JAVA); } else if(nexusResp.getData().getArtifactList()!=null && nexusResp.getData().getArtifactList().size()>1) { log.error("More than one artifact found for SHA1 [" + digest + "] in Nexus"); } else { log.info("No artifact found for SHA1 [" + digest + "] in Nexus"); } return result; }
public JarDiffResult diffJars(LibraryId _old, LibraryId _new) throws ServiceConnectionException { final String service_url = VulasConfiguration.getGlobal().getServiceUrl(Service.CIA, true); final String service_path = PathBuilder.diffArtifacts(); final String url = service_url.concat(service_path); // The artifacts to compare final Artifact[] artifacts = new Artifact[2]; artifacts[0] = ServiceWrapper.fromLibid(_old); artifacts[0].setPackaging("jar"); artifacts[0].setProgrammingLanguage(ProgrammingLanguage.JAVA); artifacts[1] = ServiceWrapper.fromLibid(_new); artifacts[1].setPackaging("jar"); artifacts[1].setProgrammingLanguage(ProgrammingLanguage.JAVA); // Make the query JarDiffResult result; URI uri = null; try { uri = new URI(url); this.logCallInfo(uri, null); final RestTemplate rest_template = new RestTemplate(); result = rest_template.postForObject(url, artifacts, JarDiffResult.class, (Object)null); }catch (HttpClientErrorException he){ throw new EntityNotFoundException(); } catch (RestClientException e) { throw new ServiceConnectionException(uri, e); } catch (URISyntaxException use) { throw new ServiceConnectionException("Cannot create service URI from [" + url + "]", use); } return result; }