* @param iObjects Not used, must be zero.
* @throws SQLException
*/
public void setUserPermissions(Connection oConn, String sIdUsers, int iACLMask, short iRecurse, short iObjects) throws SQLException {
PreparedStatement oStmt = null;
CallableStatement oCall = null;
StringTokenizer oUsrTok;
String sSQL;
String sUserId;
int iTokCount;
if (DebugFile.trace) {
DebugFile.writeln("Begin Category.setUserPermissions([Connection], " + sIdUsers + "," + iACLMask + "," + iRecurse + "," + iObjects + ")" );
DebugFile.incIdent();
DebugFile.writeln(" " + DB.gu_category + "=" + getStringNull(DB.gu_category, "null"));
}
if (oConn.getMetaData().getDatabaseProductName().equalsIgnoreCase("PostgreSQL")) {
sSQL = "SELECT k_sp_cat_set_usr (?,?," + String.valueOf(iACLMask) + ", CAST(" + String.valueOf(iRecurse) + " AS SMALLINT), CAST(" + String.valueOf(iObjects) + " AS SMALLINT))";
if (DebugFile.trace) DebugFile.writeln("Connection.prepareStatement(" + sSQL + ")");
oStmt = oConn.prepareStatement(sSQL);
} else {
sSQL = "{ call k_sp_cat_set_usr (?,?," + String.valueOf(iACLMask) + "," + String.valueOf(iRecurse) + "," + String.valueOf(iObjects) + ") }";
if (DebugFile.trace) DebugFile.writeln("Connection.prepareCall(" + sSQL + ")");
oCall = oConn.prepareCall(sSQL);
}
if (sIdUsers.indexOf(',')>0) {
oUsrTok = new StringTokenizer(sIdUsers, ",");
iTokCount = oUsrTok.countTokens();
for (int t=0; t<iTokCount; t++) {
sUserId = oUsrTok.nextToken();
if (DebugFile.trace) DebugFile.writeln("binding user " + String.valueOf(t+1) + "/" + String.valueOf(iTokCount) + " " + sUserId);
if (null!=oCall) {
oCall.setString(1, getString(DB.gu_category));
oCall.setString(2, sUserId);
oCall.execute();
} else {
oStmt.setObject(1, getString(DB.gu_category), java.sql.Types.CHAR);
oStmt.setObject(2, sUserId, java.sql.Types.CHAR);
oStmt.executeQuery().close();
}
} // end for ()
} else {
if (DebugFile.trace) DebugFile.writeln("binding user " + sIdUsers);
if (null!=oCall) {
oCall.setString(1, getString(DB.gu_category));
oCall.setString(2, sIdUsers);
if (DebugFile.trace) DebugFile.writeln("CallableStatement.execute()");
oCall.execute();
} else {
oStmt.setObject(1, getString(DB.gu_category), java.sql.Types.CHAR);
oStmt.setObject(2, sIdUsers, java.sql.Types.CHAR);
if (DebugFile.trace) DebugFile.writeln("PreparedStatement.executeQuery()");
oStmt.executeQuery().close();
}
}
if (DebugFile.trace) DebugFile.writeln("Statement.close()");
if (null!=oCall) oCall.close();
if (null!=oStmt) oStmt.close();
if (DebugFile.trace) {
DebugFile.decIdent();
DebugFile.writeln("End Category.setUserPermissions()");