Search in sources :

Example 1 with PermissionResult

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

the class OracleDatabasePlatform method getExecuteSymPermission.

@Override
public PermissionResult getExecuteSymPermission() {
    String delimiter = getDatabaseInfo().getDelimiterToken();
    delimiter = delimiter != null ? delimiter : "";
    String executeSql = "SELECT DBMS_LOB.GETLENGTH('TEST'), UTL_RAW.CAST_TO_RAW('TEST') FROM DUAL";
    PermissionResult result = new PermissionResult(PermissionType.EXECUTE, Status.FAIL);
    try {
        getSqlTemplate().update(executeSql);
        result.setStatus(Status.PASS);
    } catch (SqlException e) {
        result.setException(e);
        result.setSolution("Grant EXECUTE on DBMS_LOB and UTL_RAW");
    }
    return result;
}
Also used : PermissionResult(org.jumpmind.db.platform.PermissionResult) SqlException(org.jumpmind.db.sql.SqlException)

Example 2 with PermissionResult

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

the class MsSql2000DatabasePlatform method getCreateSymFunctionPermission.

@Override
public PermissionResult getCreateSymFunctionPermission() {
    String routineSql = "CREATE FUNCTION TEST_FUNC() RETURNS INTEGER BEGIN RETURN 1; END";
    String dropSql = "IF OBJECT_ID('TEST_FUNC') IS NOT NULL DROP FUNCTION TEST_FUNC";
    PermissionResult result = new PermissionResult(PermissionType.CREATE_FUNCTION, Status.FAIL);
    try {
        getSqlTemplate().update(dropSql);
        getSqlTemplate().update(routineSql);
        result.setStatus(Status.PASS);
        getSqlTemplate().update(dropSql);
    } catch (SqlException e) {
        result.setException(e);
        if (result.getSolution() != null) {
            result.setSolution("Grant CREATE FUNCTION Privilege");
        }
    }
    return result;
}
Also used : PermissionResult(org.jumpmind.db.platform.PermissionResult) SqlException(org.jumpmind.db.sql.SqlException)

Example 3 with PermissionResult

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

the class MsSql2000DatabasePlatform 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 + " AFTER UPDATE AS SELECT 1 GO";
    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 4 with PermissionResult

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

the class SqlAnywhereDatabasePlatform method getCreateSymTriggerPermission.

@Override
public PermissionResult getCreateSymTriggerPermission() {
    String delimiter = getDatabaseInfo().getDelimiterToken();
    delimiter = delimiter != null ? delimiter : "";
    String triggerSql = "CREATE OR REPLACE TRIGGER TEST_TRIGGER AFTER UPDATE ON " + delimiter + PERMISSION_TEST_TABLE_NAME + delimiter + " 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 5 with PermissionResult

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

the class PostgreSqlDatabasePlatform method getDropSymTriggerPermission.

@Override
public PermissionResult getDropSymTriggerPermission() {
    String dropTriggerSql = "DROP FUNCTION TEST_TRIGGER()";
    PermissionResult result = new PermissionResult(PermissionType.DROP_TRIGGER, PermissionResult.Status.FAIL);
    try {
        getSqlTemplate().update(dropTriggerSql);
        result.setStatus(PermissionResult.Status.PASS);
    } catch (SqlException e) {
        result.setException(e);
    }
    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