Search in sources :

Example 6 with PermissionResult

use of org.jumpmind.db.platform.PermissionResult in project symmetric-ds by JumpMind.

the class PostgreSqlDatabasePlatform method getCreateSymTriggerPermission.

@Override
public PermissionResult getCreateSymTriggerPermission() {
    String delimiter = getDatabaseInfo().getDelimiterToken();
    delimiter = delimiter != null ? delimiter : "";
    String triggerSql = "CREATE OR REPLACE FUNCTION TEST_TRIGGER() RETURNS trigger AS $$ BEGIN END $$ LANGUAGE plpgsql";
    PermissionResult result = new PermissionResult(PermissionType.CREATE_TRIGGER, Status.FAIL);
    try {
        getSqlTemplate().update(triggerSql);
        result.setStatus(Status.PASS);
    } catch (SqlException e) {
        result.setException(e);
        result.setSolution("Grant CREATE TRIGGER permission and/or DROP TRIGGER permission");
    }
    return result;
}
Also used : PermissionResult(org.jumpmind.db.platform.PermissionResult) SqlException(org.jumpmind.db.sql.SqlException)

Example 7 with PermissionResult

use of org.jumpmind.db.platform.PermissionResult in project symmetric-ds by JumpMind.

the class SqliteDatabasePlatform method getCreateSymTriggerPermission.

@Override
protected PermissionResult getCreateSymTriggerPermission() {
    String delimiter = getDatabaseInfo().getDelimiterToken();
    delimiter = delimiter != null ? delimiter : "";
    String triggerSql = "CREATE TRIGGER TEST_TRIGGER AFTER UPDATE ON " + delimiter + PERMISSION_TEST_TABLE_NAME + delimiter + "FOR EACH ROW BEGIN SELECT 1; END";
    PermissionResult result = new PermissionResult(PermissionType.CREATE_TRIGGER, Status.FAIL);
    try {
        getSqlTemplate().update(triggerSql);
        result.setStatus(Status.PASS);
    } catch (SqlException e) {
        result.setException(e);
        result.setSolution("Grant CREATE TRIGGER permission or TRIGGER permission");
    }
    return result;
}
Also used : PermissionResult(org.jumpmind.db.platform.PermissionResult) SqlException(org.jumpmind.db.sql.SqlException)

Example 8 with PermissionResult

use of org.jumpmind.db.platform.PermissionResult in project symmetric-ds by JumpMind.

the class DerbyDatabasePlatform method getCreateSymTriggerPermission.

@Override
public PermissionResult getCreateSymTriggerPermission() {
    String delimiter = getDatabaseInfo().getDelimiterToken();
    delimiter = delimiter != null ? delimiter : "";
    String triggerSql = "CREATE TRIGGER TEST_TRIGGER AFTER UPDATE ON " + delimiter + PERMISSION_TEST_TABLE_NAME + delimiter + " FOR EACH ROW MODE DB2SQL INSERT INTO " + delimiter + PERMISSION_TEST_TABLE_NAME + delimiter + " VALUES(NULL,NULL)";
    PermissionResult result = new PermissionResult(PermissionType.CREATE_TRIGGER, Status.FAIL);
    try {
        getSqlTemplate().update(triggerSql);
        result.setStatus(Status.PASS);
    } catch (SqlException e) {
        result.setException(e);
        result.setSolution("Grant CREATE TRIGGER permission or TRIGGER permission");
    }
    return result;
}
Also used : PermissionResult(org.jumpmind.db.platform.PermissionResult) SqlException(org.jumpmind.db.sql.SqlException)

Example 9 with PermissionResult

use of org.jumpmind.db.platform.PermissionResult in project symmetric-ds by JumpMind.

the class Db2DatabasePlatform method getCreateSymTriggerPermission.

@Override
public PermissionResult getCreateSymTriggerPermission() {
    String delimiter = getDatabaseInfo().getDelimiterToken();
    delimiter = delimiter != null ? delimiter : "";
    String triggerSql = "CREATE TRIGGER TEST_TRIGGER AFTER UPDATE ON " + delimiter + PERMISSION_TEST_TABLE_NAME + delimiter + " FOR EACH ROW BEGIN ATOMIC END";
    PermissionResult result = new PermissionResult(PermissionType.CREATE_TRIGGER, Status.FAIL);
    try {
        getSqlTemplate().update(triggerSql);
        result.setStatus(Status.PASS);
    } catch (SqlException e) {
        result.setException(e);
        result.setSolution("Grant CREATE TRIGGER permission or TRIGGER permission");
    }
    return result;
}
Also used : PermissionResult(org.jumpmind.db.platform.PermissionResult) SqlException(org.jumpmind.db.sql.SqlException)

Example 10 with PermissionResult

use of org.jumpmind.db.platform.PermissionResult in project symmetric-ds by JumpMind.

the class AseDatabasePlatform method getCreateSymTriggerPermission.

@Override
public PermissionResult getCreateSymTriggerPermission() {
    String delimiter = getDatabaseInfo().getDelimiterToken();
    delimiter = delimiter != null ? delimiter : "";
    String triggerSql = "create trigger TEST_TRIGGER on " + delimiter + PERMISSION_TEST_TABLE_NAME + delimiter + " for insert as begin select 1 end";
    PermissionResult result = new PermissionResult(PermissionType.CREATE_TRIGGER, Status.FAIL);
    try {
        getSqlTemplate().update(triggerSql);
        result.setStatus(Status.PASS);
    } catch (SqlException e) {
        result.setException(e);
        result.setSolution("Grant CREATE TRIGGER permission or TRIGGER permission");
    }
    return result;
}
Also used : PermissionResult(org.jumpmind.db.platform.PermissionResult) SqlException(org.jumpmind.db.sql.SqlException)

Aggregations

PermissionResult (org.jumpmind.db.platform.PermissionResult)18 SqlException (org.jumpmind.db.sql.SqlException)18