Пример #1
0
  public DownloadWebPackageResponse download(DownloadWebPackageRequest request) {
    logger.info(String.format("begin download WebPackage: %s", request));

    DownloadWebPackageResponse response = new DownloadWebPackageResponse();

    File webPackageFile = WebPackageUtil.newWebPackageFile(request.getToken());
    response.setFileSystemResource(new FileSystemResource(webPackageFile));
    response.success();

    logger.info(String.format("end download WebPackage: %s", response));

    return response;
  }
Пример #2
0
  public UploadWebPackageResponse upload(UploadWebPackageRequest request) {
    logger.info(String.format("begin upload WebPackage: %s", request));

    UploadWebPackageResponse response = new UploadWebPackageResponse();

    File webPackageFile = WebPackageUtil.newWebPackageFile(request.getToken());
    try {
      Files.write(request.getFile().getBytes(), webPackageFile);
      response.success();
      saveOrUpdateAppVersion(request.getToken());
    } catch (IOException e) {
      response.fail(e.toString());
      logger.error(String.format("error when upload: %s", request), e);
    }

    logger.info(String.format("end upload WebPackage: %s", response));

    return response;
  }
Пример #3
0
  public AllocateWebPackageResponse allocate(AllocateWebPackageRequest request) {

    AllocateWebPackageResponse response = new AllocateWebPackageResponse();

    try {
      logger.info(String.format("begin allocate WebPackage: %s", request));

      AppFileEntity appFile = allocateAppFile(request);
      appFileDal.insert(appFile);

      String repositoryUploadUrl = WebPackageUtil.generateUploadUrl(appFile.getToken());
      response.setUploadUrl(repositoryUploadUrl);
      response.success();
    } catch (Exception e) {
      response.fail(e.toString());
      logger.error(String.format("error when allocate WebPackage: %s", request), e);
    }

    logger.info(String.format("end allocate WebPackage: %s", response));

    return response;
  }