Dear All,

I am not using Flux because I have a small number of permissions (2), roles
(2) and am using the global group. I set these up in a service that loads
when Turbine runs. I have to admit to not fully understanding the impact of
granting a user a particular role within a group. I have read the other
threads on Security and understand the concepts but the actual nitty gritty
I expect to find out by experimentation.

The exception is saying that the UserId cannot be null and occurs when I
call the last line of the code here.

        protected void setRoleFromParameters(RunData aData, User aUser)
                throws FkException, Exception
        {
                // Get the rolepeer from the role name parameter, not good to rely on
string here

                ParameterParser parser=aData.getParameters();
                String selectedRoleName=parser.getString("selectedRoleType");

                Role role=TurbineSecurity.getRole(selectedRoleName);
                // Assume that grant is benign if user exists with this role
                Group rwtgroup = TurbineSecurity.getGroup("global");
                TurbineSecurity.grant(aUser, rwtgroup,
role);<----------------------------------This is the line it fails on
        }

I am calling this from a method in th esame action that saves the User
object just prior to calling the above method. It does not faisl so I cannot
see how th eUserId can be null.

I have attached fuller details with the exception trace in a file for those
who need more.

Thanks

David
This trace is produced from the code that follows:

[Wed Oct 31 14:06:02 GMT+00:00 2001] -- DEBUG -- CrudUser.create(): parameters 
are:{selectedroletype=Administrator}
{action=CrudUser}
{selecteduser=Admin}<--------------------------------These are the values passed in 
the parser.setProperties(user); in CrudUser
{username=[Admin], [DWynt]}
{firstname=David}
{repassword=envoy9}
{lastname=Wynter}
{[EMAIL PROTECTED]}
{eventsubmit_docreate=Create}
{selectiontype=initial}
{template=ManageUser.vm}
{password=envoy9}

[Wed Oct 31 14:06:03 GMT+00:00 2001] -- ERROR -- CrudUser.doCreate():Unable to create 
user
[Wed Oct 31 14:06:03 GMT+00:00 2001] -- ERROR -- 
        Exception:  org.apache.turbine.util.security.DataBackendException: 
grant(User,Group,Role) failed: General error: Column 'USER_ID' cannot be null
        Stack Trace follows:
        java.sql.SQLException: General error: Column 'USER_ID' cannot be null
        at org.gjt.mm.mysql.MysqlIO.sendCommand(MysqlIO.java:497)
        at org.gjt.mm.mysql.MysqlIO.sqlQueryDirect(MysqlIO.java:550)
        at org.gjt.mm.mysql.Connection.execSQL(Connection.java:885)
        at org.gjt.mm.mysql.PreparedStatement.executeUpdate(PreparedStatement.java:389)
        at com.workingdogs.village.Record.saveWithInsert(Record.java:328)
        at com.workingdogs.village.Record.save(Record.java:185)
        at com.workingdogs.village.Record.save(Record.java:166)
        at org.apache.turbine.om.peer.BasePeer.insertOrUpdateRecord(BasePeer.java:860)
        at org.apache.turbine.om.peer.BasePeer.doInsert(BasePeer.java:764)
        at org.apache.turbine.om.peer.BasePeer.doInsert(BasePeer.java:657)
        at 
org.apache.turbine.services.security.db.DBSecurityService.grant(DBSecurityService.java:217)
rethrown as org.apache.turbine.util.security.DataBackendException: 
grant(User,Group,Role) failed: General error: Column 'USER_ID' cannot be null
        at 
org.apache.turbine.services.security.db.DBSecurityService.grant(DBSecurityService.java:223)
        at 
org.apache.turbine.services.security.TurbineSecurity.grant(TurbineSecurity.java:338)
        at 
com.roamware.rwtransform.modules.actions.CrudUser.setRoleFromParameters(CrudUser.java:45)<-------------see
 below for this method
        at com.roamware.rwtransform.modules.actions.CrudUser.doCreate(CrudUser.java:75)
        ....trucated here


        
    /**
         * Create a new Turbine user
     */
    public void doCreate(RunData aData, Context aContext)
    {
                try
                {
                        logParameters(aData, "CrudUser.create()");
                        TurbineUser user = new TurbineUser();
                        // setProperties throws if the id has not been initialised,
                        // as will occur if nothing has been previously selected from
                        // the drop-down list (e.g. when no entities exist in the
                        // user).  When creating, we always want to overwrite
                        // the ID to zero
                        ParameterParser parser=aData.getParameters();
                        parser.setProperties(user); 

                        GregorianCalendar calend = new GregorianCalendar();
                        Date today=calend.getTime();
                        user.setCreateDate(today); 

                        user.setModified(true);
                        user.setNew(true);
                        try
                        {
                                user.save();
                                setRoleFromParameters(aData, 
user);<-----------------------------Fails on this call see below for method
                        }
........truncated here

    /**
         * Translate roles as selected in drop-down lists into IDs
         * and then place these IDs into the turbine_user_group_role as foreign keys
     */
        protected void setRoleFromParameters(RunData aData, User aUser)
                throws FkException, Exception
        {
                // Get the rolepeer from the role name parameter, not good to rely on 
string here 
                
                ParameterParser parser=aData.getParameters();
                String selectedRoleName=parser.getString("selectedRoleType");
                
                Role role=TurbineSecurity.getRole(selectedRoleName);
                // Assume that grant is benign if user exists with this role
                Group rwtgroup = TurbineSecurity.getGroup("global");
                TurbineSecurity.grant(aUser, rwtgroup, 
role);<----------------------------------This is the line is fails on
        }



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to