Ejemplo n.º 1
0
  @Override
  protected Navigation execute(
      UserModel acsessUserModel, UserModel loginUserModel, boolean isLogin, boolean isSmartPhone)
      throws Exception {

    String activityId = asString("activityId");
    ActivityModel activityModel = ActivityService.getActivity(activityId);

    ArrayList<ActivityModel> activityList = new ArrayList<ActivityModel>();
    if (activityModel != null) {
      activityList.add(activityModel);
    }

    // リクエストスコープの設定
    requestScope("activityList", activityList);
    if (activityModel != null) {
      if (activityModel.getTitleString() != null) {
        requestScope(
            "pageTitle", activityModel.getTitleString() + " - " + acsessUserModel.getDisplayName());

      } else if (activityModel.isAttachmentsFlg()
          && activityModel.getAttachmentsDisplayNameString() != null) {
        requestScope(
            "pageTitle",
            activityModel.getAttachmentsDisplayNameString()
                + " - "
                + acsessUserModel.getDisplayName());

      } else {
        requestScope("pageTitle", "Google+での投稿 - " + acsessUserModel.getDisplayName());
      }
    }

    return forward("/responsive/activity_only.jsp");
  }
  @Override
  public Navigation run() throws Exception {

    UserModel userModel = null;

    try {
      userModel = getUser();
    } catch (Exception e) {
      return null;
    }
    ;

    // タスクは成功するまで実行されるため、失敗時は例外をキャッチして再実行をさせない
    try {
      // アクティビティの取得
      String activityId = asString("activityId");

      ActivityModel activityModel = ActivityService.getActivity(activityId);
      if (activityModel == null) return null;

      // 短縮URLの取得
      String shortUrl = getShortUrl(userModel, activityModel);

      // Twitter メッセージの作成
      String msg = getMessage(activityModel, shortUrl);

      // POST
      if (activityModel.getAttachmentsType() != null
          && (activityModel
                  .getAttachmentsType()
                  .getCategory()
                  .equals(Constants.GOOGLE_ACTIVITY_ATTACHMENTS_TYPE_PHOTO)
              || activityModel
                  .getAttachmentsType()
                  .getCategory()
                  .equals(Constants.GOOGLE_ACTIVITY_ATTACHMENTS_TYPE_ALBUM))
          && activityModel
              .getVerb()
              .getCategory()
              .equals(Constants.GOOGLE_ACTIVITY_VERB_TYPE_POST)) {

        // 自分が投稿した写真付きの場合もしくアルバム
        imageUpload(userModel, msg, activityModel.getAttachmentsImageUrlString());

      } else {
        postMessage(userModel, msg);
      }

    } catch (Exception e) {
      logger.severe(e.toString());
    }

    return null;
  }