public void handle()

in initializer-generator/src/main/java/com/alibaba/initializer/protocol/archive/ProjectArchiveHandler.java [93:127]


    public void handle(HttpServletRequest request, HttpServletResponse response, FilterChain chain, String protocol) {
        ProjectGenerationRequest projRequest = requestConverter.convert(request);

        ProjectGenerationResult projResult = routeGenerator.generate(projRequest);

        // create archive bytes
        ResponseEntity<byte[]> entity;
        Path archive = null;
        try {
            switch (protocol) {
                case "zip":
                    archive = createArchive(projResult, "zip", ZipArchiveOutputStream::new, ZipArchiveEntry::new, ZipArchiveEntry::setUnixMode);
                    entity = upload(archive, generateFileName(projResult, "zip"), "application/zip");
                    break;
                case "tar":
                case "tar.gz":
                    archive = createArchive(projResult, "tar.gz", this::createTarArchiveOutputStream, TarArchiveEntry::new, TarArchiveEntry::setMode);
                    entity = upload(archive, generateFileName(projResult, "tar.gz"), "application/x-compress");
                    break;
                default:
                    throw new BizRuntimeException(ErrorCodeEnum.UNSUPPORTED, "not support archive type");
            }
        } catch (Exception e) {
            throw new BizRuntimeException(ErrorCodeEnum.SYSTEM_ERROR, "create archive error", e);
        } finally {
            projResult.cleanUp();
            try {
                FileSystemUtils.deleteRecursively(archive);
            } catch (IOException ignoe) {
            }
        }

        // response archive bytes
        responseArchiveBytes(entity, request, response);
    }