Creating User Ids
One can use the following custom Java method to create User Ids in the CRM Foundation module, which also returns a value that indicates if an ‘Approval’ is required for this user, based on the User type passed to this method.
Notice, the use of JTF_UM_USER_ADMIN_PVT.createSystemUser, out-of-the-box API, to create the user.
Email support@ibizsoftinc.com if you would like further support on this code.
public BigDecimal[] createSystemUser(String userName, BigDecimal tmplUserTypeId, BigDecimal userIdNumber)
throws FrameworkException {
String moduleName = “JTF.UM.JAVA.UsertypeMgmt2″;
String s1 = “createSystemUser”;
BigDecimal abigdecimal[] = new BigDecimal[2];
LoggingMgmt.logEnteringMethod(moduleName, s1);
if (LoggingMgmt.isLoggingOnForParameters(moduleName))
LoggingMgmt.logParameters(moduleName, “Parameters : username is ” + userName + ” usertypeId is ” + tmplUserTypeId + ” userId is ” + userIdNumber);
OracleConnection oracleconnection = null;
CallableStatement callablestatement = null;
try {
oracleconnection = (OracleConnection) TransactionScopeProvider.getConnection();
if (oracleconnection == null) {
if (LoggingMgmt.isLoggingOnForUnexpectedError(moduleName))
LoggingMgmt.logUnexpectedError(moduleName, “error in getting a connection”);
throw new FrameworkException(“JTA_UM_CONNECTION_ERROR”);
}
if (LoggingMgmt.isLoggingOnForParameters(moduleName))
LoggingMgmt.logParameters(moduleName, “invoking JTF_UM_USER_ADMIN_PVT.createSystemUser”);
callablestatement = oracleconnection.prepareCall(“begin JTF_UM_USER_ADMIN_PVT.Create_System_User( p_username => :1, p_usertype_id => :2, p_user_id => :3,x_user_reg_id => :4,x_approval_id => :5); end;”);
callablestatement.setString(1, userName);
callablestatement.setBigDecimal(2, tmplUserTypeId);
callablestatement.setBigDecimal(3, userIdNumber);
callablestatement.registerOutParameter(4, 2);
callablestatement.registerOutParameter(5, 2);
callablestatement.execute();
abigdecimal[0] = callablestatement.getBigDecimal(4, 0);
abigdecimal[1] = callablestatement.getBigDecimal(5, 0);
if (LoggingMgmt.isLoggingOnForParameters(moduleName))
LoggingMgmt.logParameters(moduleName, “returning from JTF_UM_USER_ADMIN_PVT.createSystemUser with parameters: x_usertype_reg_id => ” + abigdecimal[0] + ” approval id ” + abigdecimal[1]);
LoggingMgmt.logExitingMethod(moduleName, s1);
BigDecimal abigdecimal1[] = abigdecimal;
return abigdecimal1;
}
catch (SQLException sqlexception) {
TransactionScope.setRollbackOnly();
LoggingMgmt.logUnexpectedError(sqlexception, moduleName, s1);
throw new FrameworkException(sqlexception, “JTA_UM_SQL_ERROR”, “0″, s1, “1″, sqlexception.getMessage());
}
catch (Exception exception1) {
TransactionScope.setRollbackOnly();
LoggingMgmt.logUnexpectedError(exception1, moduleName, s1);
throw new FrameworkException(exception1, “JTA_UM_UNEXPECTED_ERROR”, s1);
}
finally {
if (callablestatement != null)
try {
callablestatement.close();
}
catch (Exception _ex) {
}
try {
mylog(“1″);
LoggingMgmt.setICXSessionID(oracleconnection, null);
mylog(“2″);
printContext(“3″);
TransactionScope.releaseConnection(oracleconnection);
printContext(“4″);
mylog(“3″);
} catch (Exception _ex) {
}
}
}
There are no comments yet.