use of alien4cloud.deployment.exceptions.UnresolvableArtifactException in project alien4cloud by alien4cloud.
the class ArtifactProcessorService method processLocalArtifact.
private void processLocalArtifact(AbstractArtifact artifact) {
try {
Path csarPath = repository.getExpandedCSAR(artifact.getArchiveName(), artifact.getArchiveVersion());
Path resolvedPath = csarPath.resolve(artifact.getArtifactRef());
if (!Files.exists(resolvedPath)) {
throw new UnresolvableArtifactException("Artifact could not be accessed " + artifact);
}
artifact.setArtifactPath(resolvedPath.toString());
} catch (NotFoundException e) {
throw new UnresolvableArtifactException("Artifact could not be found " + artifact, e);
}
}
use of alien4cloud.deployment.exceptions.UnresolvableArtifactException in project alien4cloud by alien4cloud.
the class ArtifactProcessorService method processArtifact.
private void processArtifact(AbstractArtifact artifact) {
if (ArtifactRepositoryConstants.ALIEN_ARTIFACT_REPOSITORY.equals(artifact.getArtifactRepository())) {
artifact.setArtifactPath(artifactRepository.resolveFile(artifact.getArtifactRef()).toString());
return;
}
URL artifactURL = null;
if (artifact.getRepositoryName() == null) {
// Short notation
try {
// Test if it's an URL
artifactURL = new URL(artifact.getArtifactRef());
} catch (MalformedURLException e) {
if (log.isDebugEnabled()) {
log.debug("Processing local artifact {}", artifact);
}
// Not a URL then must be a relative path to a file inside the csar
processLocalArtifact(artifact);
return;
}
}
if (log.isDebugEnabled()) {
log.debug("Processing remote artifact {}", artifact);
}
String artifactPath = resolveArtifact(artifact);
if (artifactPath == null) {
if (artifactURL != null) {
try (InputStream artifactStream = artifactURL.openStream()) {
// In a best effort try in a generic manner to obtain the artifact
Path tempPath = Files.createTempFile(tempDir, "url-artifact", FilenameUtils.getExtension(artifact.getArtifactRef()));
artifactPath = tempPath.toString();
Files.copy(artifactStream, tempPath, StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
throw new UnresolvableArtifactException("Artifact could not be found " + artifact, e);
}
} else {
throw new UnresolvableArtifactException("Artifact could not be found " + artifact);
}
}
if (log.isDebugEnabled()) {
log.debug("Remote artifact from {} resolved to {}", artifact.getArtifactRef(), artifactPath);
}
artifact.setArtifactPath(artifactPath);
}
Aggregations