コード例 #1
0
ファイル: DBCleanService.java プロジェクト: pkdevbox/jcr
  /**
   * Returns database cleaner for workspace.
   *
   * @param jdbcConn database connection which need to use
   * @param wsEntry workspace configuration
   * @return DBCleanerTool
   * @throws DBCleanException
   */
  public static DBCleanerTool getWorkspaceDBCleaner(Connection jdbcConn, WorkspaceEntry wsEntry)
      throws DBCleanException {
    SecurityHelper.validateSecurityPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);

    String dialect = resolveDialect(jdbcConn, wsEntry);
    boolean autoCommit = dialect.startsWith(DialectConstants.DB_DIALECT_SYBASE);

    DBCleaningScripts scripts = DBCleaningScriptsFactory.prepareScripts(dialect, wsEntry);

    return new DBCleanerTool(
        jdbcConn,
        autoCommit,
        scripts.getCleaningScripts(),
        scripts.getCommittingScripts(),
        scripts.getRollbackingScripts());
  }
コード例 #2
0
ファイル: DBCleanService.java プロジェクト: pkdevbox/jcr
  /**
   * Returns database cleaner for repository.
   *
   * @param jdbcConn database connection which need to use
   * @param rEntry repository configuration
   * @return DBCleanerTool
   * @throws DBCleanException
   */
  public static DBCleanerTool getRepositoryDBCleaner(Connection jdbcConn, RepositoryEntry rEntry)
      throws DBCleanException {
    SecurityHelper.validateSecurityPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);

    WorkspaceEntry wsEntry = rEntry.getWorkspaceEntries().get(0);

    boolean multiDb = getMultiDbParameter(wsEntry);
    if (multiDb) {
      throw new DBCleanException(
          "It is not possible to create cleaner with common connection for multi database repository configuration");
    }

    String dialect = resolveDialect(jdbcConn, wsEntry);
    boolean autoCommit = dialect.startsWith(DialectConstants.DB_DIALECT_SYBASE);

    DBCleaningScripts scripts = DBCleaningScriptsFactory.prepareScripts(dialect, rEntry);

    return new DBCleanerTool(
        jdbcConn,
        autoCommit,
        scripts.getCleaningScripts(),
        scripts.getCommittingScripts(),
        scripts.getRollbackingScripts());
  }