String subpath = each.getPath().substring(scriptTemplateDir.getPath().length());
String fileContent = FileUtils.readFileToString(each, "UTF8");
fileContent = fileContent.replace("${userName}", user.getUserName());
fileContent = fileContent.replace("${name}", name);
fileContent = fileContent.replace("${url}", url);
FileEntry fileEntry = new FileEntry();
fileEntry.setContent(fileContent);
fileEntry.setPath(FilenameUtils.normalize(PathUtils.join(path, subpath), true));
fileEntry.setDescription("create groovy maven project");
String hostName = UrlUtils.getHost(url);
if (StringUtils.isNotEmpty(hostName)
&& fileEntry.getFileType().getFileCategory() == FileCategory.SCRIPT) {
Map<String, String> properties = newHashMap();
properties.put("targetHosts", UrlUtils.getHost(url));
fileEntry.setProperties(properties);
}
getFileEntryRepository().save(user, fileEntry, "UTF8");
} catch (IOException e) {
throw processException("Error while saving " + each.getName(), e);
}