public static String getBasePackagePath(SkeletonProperties skeletonProperties) { return getBasePackagePath(null, skeletonProperties); }
public static String getCanonicalPath(String generatePath, String fileName, SkeletonProperties skeletonProperties) { return formatGeneratePath(generatePath) + getCanonicalFileName(fileName, skeletonProperties); }
public static String getOutputPath(String generatePath, String projectType, SkeletonProperties skeletonProperties) { return formatGeneratePath(generatePath) + (StringUtils.isNotEmpty(projectType) ? getBaseDirectoryName(projectType, skeletonProperties) + "/" : ""); }
private void initialize() { String generatePath = skeletonContext.getGeneratePath(); String projectType = skeletonContext.getProjectType(); defaultBasePackage = SkeletonUtil.getBasePackagePath(projectType, skeletonProperties); defaultOutputPath = SkeletonUtil.getOutputPath(generatePath, projectType, skeletonProperties); }
public byte[] download(String generatePath, String fileName, SkeletonProperties skeletonProperties) { if (StringUtils.isEmpty(generatePath)) { generatePath = SkeletonUtil.getTempGeneratePath(); } if (StringUtils.isEmpty(fileName)) { throw new SkeletonException("File name is null or empty"); } try { String canonicalPath = SkeletonUtil.getCanonicalPath(generatePath, fileName, skeletonProperties); generate(canonicalPath, skeletonProperties); String zipFilePath = ZipUtil.zip(canonicalPath, null); File zipFile = new File(zipFilePath); LOG.info("Download skeleton file for " + zipFile.getName() + " is executed"); return FileUtil.getBytes(zipFile); } catch (Exception e) { throw new SkeletonException(e.getMessage(), e); } finally { File directory = new File(generatePath); FileUtil.forceDeleteDirectory(directory, 5); } }
public static String getTempGeneratePath() { String tempGeneratePath = formatGeneratePath(System.getProperty("java.io.tmpdir")) + SkeletonConstant.SKELETON; return tempGeneratePath; } }
public static String getBaseDirectoryName(SkeletonProperties skeletonProperties) { return getBaseDirectoryName(null, skeletonProperties); }
public static String getOutputPath(String generatePath, SkeletonProperties skeletonProperties) { return getOutputPath(generatePath, null, skeletonProperties); }
public String getCanonicalFileName(String fileName, SkeletonProperties skeletonProperties) { if (StringUtils.isEmpty(fileName)) { throw new SkeletonException("File name is null or empty"); } try { String canonicalFileName = SkeletonUtil.getCanonicalFileName(fileName, skeletonProperties); return URLEncoder.encode(canonicalFileName + ".zip", SkeletonConstant.ENCODING_UTF_8); } catch (UnsupportedEncodingException e) { throw new SkeletonException(e.getMessage(), e); } }
public static String getBasePackagePath(String projectType, SkeletonProperties skeletonProperties) { String projectName = skeletonProperties.getString(SkeletonConstant.PROJECT_NAME); return skeletonProperties.getString(SkeletonConstant.BASE_PACKAGE) + "." + formatProjectName(projectName) + (StringUtils.isNotEmpty(projectType) ? "." + projectType : ""); }
private String generateTemplatePath() { if (generatorClass != null) { return SkeletonConstant.FILE_SEPARATOR + (StringUtils.isNotEmpty(prefixTemplatePath) ? prefixTemplatePath + SkeletonConstant.FILE_SEPARATOR : "") + SkeletonUtil.formatGeneratePath(generatorClass, reducedTemplatePath); } return SkeletonConstant.FILE_SEPARATOR + SkeletonUtil.formatGeneratePath(baseTemplatePath) + (StringUtils.isNotEmpty(projectType) ? projectType : "") + SkeletonConstant.FILE_SEPARATOR + fileType; } }
public static String getCanonicalFileName(String fileName, SkeletonProperties skeletonProperties) { return fileName + "-" + getBaseDirectoryName(skeletonProperties); }
private void initialize() { /*SkeletonFileType fileType = skeletonContext.getFileType(); if (fileType != null && fileType == SkeletonFileType.JAVA) { throw new SkeletonException("Invalid file type for " + fileType); }*/ String generatePath = skeletonContext.getGeneratePath(); String projectType = skeletonContext.getProjectType(); defaultOutputPath = SkeletonUtil.getOutputPath(generatePath, projectType, skeletonProperties); }
@Override protected Object getDataModel() { Map<String, Object> dataModel = new HashMap<String, Object>(); dataModel.put("parentPomArtifactId", skeletonProperties.getString("pomArtifactId")); dataModel.put("pomGroupId", skeletonProperties.getString("pomGroupId")); dataModel.put("pomArtifactId", skeletonProperties.getString("pomArtifactId") + "-" + getSkeletonContext().getProjectType()); dataModel.put("pomName", skeletonProperties.getString("pomName") + " " + StringUtil.firstLetterToUpper(getSkeletonContext().getProjectType())); dataModel.put("pomVersion", skeletonProperties.getString("pomVersion")); dataModel.put("javaImageVersion", skeletonProperties.getString("javaImageVersion")); dataModel.put("mainClass", SkeletonUtil.getBasePackagePath(getSkeletonContext().getProjectType(), skeletonProperties) + "." + StringUtil.firstLetterToUpper(getSkeletonContext().getProjectType()) + "Application"); dataModel.put("clientHystrixEnabled", skeletonProperties.getString("clientHystrixEnabled")); return dataModel; } }
@Override protected String getPath() throws SkeletonException { String fileName = null; String outputPath = null; Object dataModel = null; try { fileName = getFileName(); outputPath = getOutputPath(); dataModel = getDataModel(); } catch (Exception e) { throw new SkeletonException(e.getMessage(), e); } String fullPath = SkeletonUtil.formatGeneratePath(outputPath) + fileName; LOG.info("--------------- File Generator Information ---------------"); LOG.info("Template Path : {}", getSkeletonContext().getConfig().getTemplatePath() + SkeletonConstant.FILE_SEPARATOR + getTemplateName()); LOG.info("Output Path : {}", fullPath); LOG.info("Data Model : {}", dataModel); LOG.info("----------------------------------------------------------"); return fullPath; }
@Override protected Object getDataModel() { Map<String, Object> dataModel = new HashMap<String, Object>(); dataModel.put("springBootVersion", skeletonProperties.getString("springboot-version")); // dataModel.put("springCloudVersion", skeletonProperties.getString("springCloudVersion")); dataModel.put("javaVersion", skeletonProperties.getString("javaVersion")); dataModel.put("pomGroupId", skeletonProperties.getString("pomGroupId")); dataModel.put("pomArtifactId", skeletonProperties.getString("pomArtifactId") + "-" + getSkeletonContext().getProjectType()); dataModel.put("pomName", skeletonProperties.getString("pomArtifactId") + " " + StringUtil.firstLetterToUpper(getSkeletonContext().getProjectType())); // dataModel.put("pomVersion", skeletonProperties.getString("pomVersion")); // dataModel.put("javaImageVersion", skeletonProperties.getString("javaImageVersion")); dataModel.put("mainClass", SkeletonUtil.getBasePackagePath(getSkeletonContext().getProjectType(), skeletonProperties) + "." + StringUtil.firstLetterToUpper(getSkeletonContext().getProjectType()) + "Application"); return dataModel; } }
@Override protected String getPath() throws SkeletonException { String className = null; String packagePath = null; String outputPath = null; boolean isMainCode = true; Object dataModel = null; try { className = getClassName(); packagePath = getPackage(); outputPath = getOutputPath(); isMainCode = isMainCode(); dataModel = getDataModel(); } catch (Exception e) { throw new SkeletonException(e.getMessage(), e); } String fullPath = SkeletonUtil.formatGeneratePath(outputPath) + (isMainCode ? SkeletonConstant.MAIN_JAVA_CODE_PATH : SkeletonConstant.TEST_JAVA_CODE_PATH) + packagePath.replace(".", SkeletonConstant.FILE_SEPARATOR) + SkeletonConstant.FILE_SEPARATOR + className + "." + SkeletonConstant.JAVA; LOG.info("--------------- Java Generator Information ---------------"); LOG.info("Template Path : {}", getSkeletonContext().getConfig().getTemplatePath() + SkeletonConstant.FILE_SEPARATOR + getTemplateName()); LOG.info("Output Path : {}", fullPath); LOG.info("Package : {}", packagePath); LOG.info("Data Model : {}", dataModel); LOG.info("----------------------------------------------------------"); return fullPath; }