Colin Chalmers wrote:
> I'm looking at extending (replacing) the Turbine database to suit my needs. I'm 
>trying to do
> this step by step so I can understand what I'm doing.
> 
> First I'm trying to add an extra column to the present visitor database and try to 
>see/alter
> that through the webinterface. The next step would be to set up a database based on 
>Turbine
> but called something else.
> 
> Apart from the screens/actions files that need to be changed what else should I 
>think of
> changing; TurbineUserPeer and TurbineMapBuilder??
> 
> I looked at the TurbineUserPeer and thought naively that the following code would do 
>the
> trick.
> 
> Colin
> 
>     /** The key name for the last name field. */
>     public static final String EXTRA_COLUMN = "EXTRA";
> 
>    /** The key name for the last name field. */
>     public static final String EXTRA = TABLE_NAME + "." + EXTRA_COLUMN;

I'm sorry to say that but these things are going to change a lot soon. 
I will commit to check in new security code within a few days, and it's
going to change database schemas, TurbineMapBuilder, TurbineUserPeer
and other classes. If you wish to take look at the new code, please
check out security_01-branch. The code will compile (except the admin
application, which I recommed to remove from your snapshot), and 
work - we are using it in our project already.

I can tell you about solving your problem in the new system:

First, you would extend TurbineUser class

public class CustomUser extends TurbineUser {

    public static final String CUSTOM_KEY = "CUSTOM";

    public String getCustom()
    {
        return (String)getPerm(CUSTOM_KEY);
    }

    pulic void setCustom(String v)
    {
        setPerm(CUSTOM_KEY, v);
    }
}

And you would cast User to TurbineUser, any time you take it
from the RunData. You could also use getPerm() directly, but
the above approach is probably more error-proof, and allows
you to put some custom logic in the User class as well.

If you wish to be able to search you set of users using the
value of your custom column, you should use ALTER TABLE to
add your column to the DB schema. You don't need to modify
TurbineMapBuilder nor any other class.
Then, you can use:

Criteria criteria = new Criteria();
criteria.add(CustomUser.CUSTOM_KEY, "some_value%", Criteria.LIKE);
User[] users = TurbineSecrity.getUsers(criteria);

If you don't need this searching capability, don't bother yourself
with changing the database. It will just work :)

There are other neat features, and I don't feel like recalling 
all of them right now. I promise I will write a long manual for
the security system :)

I'm happy to announce that I'm done with the most of the other work 
that I had in my current project, and I'm getting to writnig a 
new admin aplication, which was the missing piece of the puzzle.

Rafal

--
Rafal Krzewski
Senior Internet Developer
mailto:[EMAIL PROTECTED]
+48 22 8534830 http://e-point.pl


------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to