LOGGER.debug("Upload new artifact from {}", url);
String artifactName = "artifact-" + System.currentTimeMillis();
File temp = new File(new File(this.getLocation()), artifactName);
FileUtils.copyURLToFile(url, temp);
// update the repository.xml
ResourceImpl resource = (ResourceImpl) new DataModelHelperImpl().createResource(temp.toURI().toURL());
if (resource == null) {
temp.delete();
LOGGER.warn("The {} artifact source is not a valid OSGi bundle", url);
return;
}
File destination = new File(new File(this.getLocation()), resource.getSymbolicName() + "-" + resource.getVersion() + ".jar");
FileUtils.moveFile(temp, destination);
resource = (ResourceImpl) new DataModelHelperImpl().createResource(destination.toURI().toURL());
this.addResource(resource);
this.generateRepositoryXml();
}