コード例 #1
0
  public void downloadApp(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    long appPackageId = ParamUtil.getLong(actionRequest, "appPackageId");
    boolean unlicensed = ParamUtil.getBoolean(actionRequest, "unlicensed");

    File file = null;

    try {
      file = FileUtil.createTempFile();

      downloadApp(actionRequest, actionResponse, appPackageId, unlicensed, file);

      App app = _appService.updateApp(file);

      JSONObject jsonObject = getAppJSONObject(app.getRemoteAppId());

      jsonObject.put("cmd", "downloadApp");
      jsonObject.put("message", "success");

      writeJSON(actionRequest, actionResponse, jsonObject);
    } finally {
      if (file != null) {
        file.delete();
      }
    }
  }
コード例 #2
0
  protected static List<String> getAppCategories(List<App> apps) {
    List<String> categories = new ArrayList<>(apps.size());

    for (App app : apps) {
      if (Validator.isNotNull(app.getCategory())) {
        categories.add(app.getCategory());
      }
    }

    return categories;
  }
コード例 #3
0
  protected JSONObject getAppJSONObject(long remoteAppId) throws Exception {
    JSONObject jsonObject = JSONFactoryUtil.createJSONObject();

    App app = _appLocalService.fetchRemoteApp(remoteAppId);

    if (app != null) {
      jsonObject.put("appId", app.getRemoteAppId());
      jsonObject.put("downloaded", app.isDownloaded());
      jsonObject.put("installed", app.isInstalled());
      jsonObject.put("version", app.getVersion());
    } else {
      jsonObject.put("appId", remoteAppId);
      jsonObject.put("downloaded", false);
      jsonObject.put("installed", false);
      jsonObject.put("version", StringPool.BLANK);
    }

    return jsonObject;
  }
コード例 #4
0
  public void updateApp(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    long appPackageId = ParamUtil.getLong(actionRequest, "appPackageId");
    boolean unlicensed = ParamUtil.getBoolean(actionRequest, "unlicensed");
    String orderUuid = ParamUtil.getString(actionRequest, "orderUuid");
    String productEntryName = ParamUtil.getString(actionRequest, "productEntryName");

    File file = null;

    try {
      file = FileUtil.createTempFile();

      downloadApp(actionRequest, actionResponse, appPackageId, unlicensed, file);

      App app = _appService.updateApp(file);

      if (Validator.isNull(orderUuid) && Validator.isNotNull(productEntryName)) {

        orderUuid = MarketplaceLicenseUtil.getOrder(productEntryName);
      }

      if (Validator.isNotNull(orderUuid)) {
        MarketplaceLicenseUtil.registerOrder(orderUuid, productEntryName);
      }

      _appService.installApp(app.getRemoteAppId());

      JSONObject jsonObject = getAppJSONObject(app.getRemoteAppId());

      jsonObject.put("cmd", "updateApp");
      jsonObject.put("message", "success");

      writeJSON(actionRequest, actionResponse, jsonObject);
    } finally {
      if (file != null) {
        file.delete();
      }
    }
  }