/**
   * Boolean検索のテスト用データを削除する.
   *
   * @param entityTypeName エンティティタイプ名
   */
  protected void deleteTestData(String entityTypeName) {
    // UserODataの削除
    UserDataUtils.delete(DcCoreConfig.getMasterToken(), -1, entityTypeName, "boolTrue", colName);
    UserDataUtils.delete(DcCoreConfig.getMasterToken(), -1, entityTypeName, "boolFalse", colName);
    UserDataUtils.delete(DcCoreConfig.getMasterToken(), -1, entityTypeName, "boolNull", colName);

    // EntityTypeの削除
    EntityTypeUtils.delete(
        colName,
        DcCoreConfig.getMasterToken(),
        MediaType.APPLICATION_JSON,
        entityTypeName,
        boxName,
        cellName,
        -1);
  }
  /**
   * Boolean検索のテスト用データを作成する.
   *
   * @param entityTypeName エンティティタイプ名
   */
  @SuppressWarnings("unchecked")
  protected void createTestData(String entityTypeName) {
    // Booleanの検索のテスト用エンティティタイプ作成
    EntityTypeUtils.create(
        cellName,
        DcCoreConfig.getMasterToken(),
        boxName,
        colName,
        entityTypeName,
        HttpStatus.SC_CREATED);

    // 真偽値が true / false / null のデータを作成
    JSONObject body = new JSONObject();
    body.put("__id", "boolTrue");
    body.put("bool", true);
    UserDataUtils.create(
        DcCoreConfig.getMasterToken(),
        HttpStatus.SC_CREATED,
        body,
        cellName,
        boxName,
        colName,
        entityTypeName);

    body.put("__id", "boolFalse");
    body.put("bool", false);
    UserDataUtils.create(
        DcCoreConfig.getMasterToken(),
        HttpStatus.SC_CREATED,
        body,
        cellName,
        boxName,
        colName,
        entityTypeName);

    body.put("__id", "boolNull");
    body.put("bool", null);
    UserDataUtils.create(
        DcCoreConfig.getMasterToken(),
        HttpStatus.SC_CREATED,
        body,
        cellName,
        boxName,
        colName,
        entityTypeName);
  }
Esempio n. 3
0
  /**
   * 削除対象のDB名とセルIDを追加する.
   *
   * @param dbName DB名
   * @param cellId セルID
   */
  public void insertCellDeleteRecord(String dbName, String cellId) {
    if (!isValid()) {
      return;
    }
    try {
      ads.insertCellDeleteRecord(dbName, cellId);
      log.info("Ads Deletion Success.");
    } catch (AdsException e) {
      // 削除対象のDB名とセルIDの追加に失敗した場合はログを出力して処理を続行する
      log.info(
          String.format(
              "Insert CELL_DELETE Record To Ads Failed. db_name:[%s], cell_id:[%s]",
              dbName, cellId),
          e);

      // Adsの登録に失敗した場合は、専用のログに書込む
      // Cell再帰削除のときは、DB名、Cell IDのみログに書込む
      // ※Cell再帰削除時にAdsに登録する情報としては、他にTable名があるが、ここでは意識しない
      AdsWriteFailureLogWriter adsWriteFailureLogWriter =
          AdsWriteFailureLogWriter.getInstance(
              DcCoreConfig.getAdsWriteFailureLogDir(),
              DcCoreConfig.getCoreVersion(),
              DcCoreConfig.getAdsWriteFailureLogPhysicalDelete());
      AdsWriteFailureLogInfo loginfo =
          new AdsWriteFailureLogInfo(
              dbName,
              null,
              null,
              null,
              cellId,
              AdsWriteFailureLogInfo.OPERATION_KIND.PCS_MANAGEMENT_INSERT,
              0,
              0);
      try {
        adsWriteFailureLogWriter.writeActiveFile(loginfo);
      } catch (AdsWriteFailureLogException e2) {
        DcCoreLog.Server.WRITE_ADS_FAILURE_LOG_ERROR.reason(e2).writeLog();
        DcCoreLog.Server.WRITE_ADS_FAILURE_LOG_INFO.params(loginfo.toString());
      }
    }
  }
Esempio n. 4
0
  /** コレクション配下のコレクション最大数チェックのテスト. */
  @Test
  public final void コレクション配下のコレクション最大数チェックのテスト() {
    // propertyで指定した要素数を超えた場合、エラーとなることを確認する。
    String cellName = "collectionLimitCell";
    String boxName = "box1";
    String colNamePrefix = "col";
    try {
      // テスト用Cellの作成
      CellUtils.create(cellName, TOKEN, HttpStatus.SC_CREATED);
      // テスト用Boxの作成
      BoxUtils.create(cellName, boxName, TOKEN, HttpStatus.SC_CREATED);

      // コレクションの子要素数の最大値を取得
      int maxChildCount = DcCoreConfig.getMaxChildResourceCount();

      // 基底コレクションの作成
      String basePath = "col1";
      Http.request("box/mkcol-normal.txt")
          .with("cellPath", cellName)
          .with("path", basePath)
          .with("token", TOKEN)
          .returns()
          .statusCode(HttpStatus.SC_CREATED);

      // 子コレクションの作成
      String path = "";
      int i;
      for (i = 1; i <= maxChildCount; i++) {
        path = basePath + "/" + colNamePrefix + String.valueOf(i);
        // Davコレクションの作成
        Http.request("box/mkcol-normal.txt")
            .with("cellPath", cellName)
            .with("path", path)
            .with("token", TOKEN)
            .returns()
            .statusCode(HttpStatus.SC_CREATED);
      }

      // 最大値を超える分の子コレクションを作成
      path = basePath + "/" + colNamePrefix + String.valueOf(i);
      // Davコレクションの作成
      Http.request("box/mkcol-normal.txt")
          .with("cellPath", cellName)
          .with("path", path)
          .with("token", TOKEN)
          .returns()
          .statusCode(HttpStatus.SC_BAD_REQUEST);
    } finally {
      // Cellの再帰的削除
      Setup.cellBulkDeletion(cellName);
    }
  }
Esempio n. 5
0
 /** コンストラクタ. */
 public CellDeleteAccessor() {
   try {
     if (DcCoreConfig.getEsAdsType().equals(DcCoreConfig.ES.ADS.TYPE_JDBC)) {
       ads = new JdbcAds();
     } else {
       ads = null;
     }
   } catch (AdsConnectionException e) {
     // 接続エラー時は接続エラーのログを出力する.
     DcCoreLog.Server.ADS_CONNECTION_ERROR.params(e.getMessage()).reason(e).writeLog();
     throw DcCoreException.Server.ADS_CONNECTION_ERROR;
   }
 }
 /** UserDataにboolean型のPropertyに範囲検索クエリを指定した場合_400エラーとなること. */
 @Test
 public final void UserDataにboolean型のPropertyに範囲検索クエリを指定した場合_400エラーとなること() {
   String sdEntityTypeName = "SalesDetail";
   // ユーザデータの一覧取得
   Http.request("box/odatacol/list.txt")
       .with("cell", cellName)
       .with("box", boxName)
       .with("collection", colName)
       .with("entityType", sdEntityTypeName)
       .with("query", "?\\$filter=truth+ge+true&\\$inlinecount=allpages")
       .with("accept", MediaType.APPLICATION_JSON)
       .with("token", DcCoreConfig.getMasterToken())
       .returns()
       .statusCode(HttpStatus.SC_BAD_REQUEST)
       .debug();
 }
  /** UserDataに部分一致検索クエリに真偽値falseを指定した場合ステータスコード400が返却されること. */
  @Test
  public final void UserDataに部分一致検索クエリに真偽値falseを指定した場合ステータスコード400が返却されること() {
    // ユーザデータの一覧取得
    String sdEntityTypeName = "SalesDetail";

    Http.request("box/odatacol/list.txt")
        .with("cell", cellName)
        .with("box", boxName)
        .with("collection", colName)
        .with("entityType", sdEntityTypeName)
        .with("query", "?\\$filter=substringof%28false%2ctruth%29")
        .with("accept", MediaType.APPLICATION_JSON)
        .with("token", DcCoreConfig.getMasterToken())
        .returns()
        .statusCode(HttpStatus.SC_BAD_REQUEST)
        .debug();
  }
Esempio n. 8
0
  /** 階層チェックのテスト_WebDavコレクションの追加. */
  @Test
  public final void 階層チェックのテスト() {
    // propertyで指定した階層数を超えた場合、エラーとなることを確認する。
    String cellName = "collectionLimitCell";
    String boxName = "box1";
    String colNamePrefix = "col";
    try {
      // テスト用Cellの作成
      CellUtils.create(cellName, TOKEN, HttpStatus.SC_CREATED);
      // テスト用Boxの作成
      BoxUtils.create(cellName, boxName, TOKEN, HttpStatus.SC_CREATED);

      // コレクションの階層数の最大値を取得
      int maxCollectionDepth = DcCoreConfig.getMaxCollectionDepth();

      // 最大値階層分のWebDavコレクションを作成
      String path = "";
      int i;
      for (i = 1; i <= maxCollectionDepth; i++) {
        if (!path.isEmpty()) {
          path += "/";
        }
        path += colNamePrefix + String.valueOf(i);
        // Davコレクションの作成
        Http.request("box/mkcol-normal.txt")
            .with("cellPath", cellName)
            .with("path", path)
            .with("token", TOKEN)
            .returns()
            .statusCode(HttpStatus.SC_CREATED);
      }

      // 最大値を超える分のWebDavコレクションを作成
      path += "/" + colNamePrefix + String.valueOf(i);
      // Davコレクションの作成(400エラーになること)
      Http.request("box/mkcol-normal.txt")
          .with("cellPath", cellName)
          .with("path", path)
          .with("token", TOKEN)
          .returns()
          .statusCode(HttpStatus.SC_BAD_REQUEST);
    } finally {
      // Cellの再帰的削除
      Setup.cellBulkDeletion(cellName);
    }
  }
Esempio n. 9
0
  /**
   * PropertyをEntityTypeからのNP経由で登録する.
   *
   * @param token トークン
   * @param cell セル名
   * @param box ボックス名
   * @param collection コレクション名
   * @param entityTypeName EntityType名
   * @param propertyName Property名
   * @param type PropertyのType項目
   * @param nullable PropertyのNullable項目
   * @param defaultValue PropertyのDefaultValue項目
   * @param collectionKind PropertyのcollectionKind項目
   * @param isKey PropertyのisKey項目
   * @param uniqueKey PropertyのUniqueKey項目
   * @param code 期待するレスポンスコード
   * @return レスポンス
   */
  @SuppressWarnings("unchecked")
  public static TResponse createViaPropertyNP(
      String token,
      String cell,
      String box,
      String collection,
      String entityTypeName,
      String propertyName,
      String type,
      Boolean nullable,
      String defaultValue,
      String collectionKind,
      Boolean isKey,
      String uniqueKey,
      int code) {

    // リクエストボディの組み立て
    JSONObject body = new JSONObject();
    body.put("Name", propertyName);
    body.put("_EntityType.Name", entityTypeName);
    body.put("Type", type);
    body.put("Nullable", nullable);
    body.put("DefaultValue", defaultValue);
    body.put("CollectionKind", collectionKind);
    body.put("IsKey", isKey);
    body.put("UniqueKey", uniqueKey);

    TResponse res =
        Http.request("box/odatacol/schema/createViaNP.txt")
            .with("cell", cell)
            .with("box", box)
            .with("collection", collection)
            .with("accept", MediaType.APPLICATION_JSON)
            .with("contentType", MediaType.APPLICATION_JSON)
            .with("token", DcCoreConfig.getMasterToken())
            .with("entityType", "EntityType")
            .with("id", entityTypeName)
            .with("navPropName", "_Property")
            .with("body", body.toJSONString())
            .returns()
            .statusCode(code)
            .debug();
    return res;
  }
Esempio n. 10
0
  /** 階層チェックのテスト_WebDavファイルの追加. */
  @Test
  public final void 階層チェックのテスト_WebDavファイルの追加() {
    String cellName = "collectionLimitCell";
    String boxName = "box1";
    String colNamePrefix = "col";
    try {
      // テスト用Cellの作成
      CellUtils.create(cellName, TOKEN, HttpStatus.SC_CREATED);
      // テスト用Boxの作成
      BoxUtils.create(cellName, boxName, TOKEN, HttpStatus.SC_CREATED);

      // コレクションの階層数の最大値を取得
      int maxCollectionDepth = DcCoreConfig.getMaxCollectionDepth();

      // 最大値階層分のWebDavコレクションを作成
      String path = "";
      int i;
      for (i = 1; i <= maxCollectionDepth; i++) {
        if (!path.isEmpty()) {
          path += "/";
        }
        path += colNamePrefix + String.valueOf(i);
        // Davコレクションの作成
        Http.request("box/mkcol-normal.txt")
            .with("cellPath", cellName)
            .with("path", path)
            .with("token", TOKEN)
            .returns()
            .statusCode(HttpStatus.SC_CREATED);
      }

      // WebDavファイルを作成
      path += "hoge.txt";
      // Davファイルの作成
      DavResourceUtils.createWebDavFile(
          cellName, TOKEN, "box/dav-put.txt", "hoge", boxName, path, HttpStatus.SC_CREATED);
    } finally {
      // Cellの再帰的削除
      Setup.cellBulkDeletion(cellName);
    }
  }