use of alien4cloud.component.repository.exception.CSARDirectoryCreationFailureException in project alien4cloud by alien4cloud.
the class CsarFileRepository method setRootPath.
@Required
@Value("${directories.alien}/${directories.csar_repository}")
public void setRootPath(String path) {
this.rootPath = Paths.get(path).toAbsolutePath();
if (!Files.isDirectory(rootPath)) {
try {
Files.createDirectories(rootPath);
log.info("Alien Repository folder set to " + rootPath.toAbsolutePath());
} catch (IOException e) {
throw new CSARDirectoryCreationFailureException("Error while trying to create the CSAR repository <" + rootPath.toString() + ">. " + e.getMessage(), e);
}
} else {
log.info("Alien Repository folder already created! " + rootPath.toAbsolutePath());
}
}
use of alien4cloud.component.repository.exception.CSARDirectoryCreationFailureException in project alien4cloud by alien4cloud.
the class CsarFileRepository method storeCSAR.
@Override
public synchronized void storeCSAR(Csar csar, String yaml) {
Path csarDirectoryPath = rootPath.resolve(csar.getName()).resolve(csar.getVersion());
String realName = csar.getName().concat("-").concat(csar.getVersion()).concat("." + CSAR_EXTENSION);
createCSARDirectory(csarDirectoryPath, realName);
Path csarExpandedDirectoryPath = csarDirectoryPath.resolve(EXPANDED);
try {
Files.createDirectories(csarExpandedDirectoryPath);
Path targetPath = csarExpandedDirectoryPath.resolve(csar.getYamlFilePath());
try (BufferedWriter writer = Files.newBufferedWriter(targetPath)) {
writer.write(yaml);
}
} catch (IOException e) {
throw new CSARDirectoryCreationFailureException("Error while trying to create the CSAR directory <" + csarDirectoryPath.toString() + ">. " + e.getMessage(), e);
}
}
Aggregations