Scott Eade <[EMAIL PROTECTED]> writes:

>1. When I define the structure of CUSTOM_USER I want to do this
>in the project schema file rather than the turbine schema file
>so that I can have foreign keys to CUSTOM_USER.  As a result I
>will pretty much move everything from the turbine schema file
>into my project's schema file (in order to have all of the
>foreign-key references).  Unlike in the past where I would
>define a table as an alias of TurbineUser I should no longer
>bother with this and just configure turbine to use the om
>classes generated for my project.  Is this correct?

Yes. The fact that Torque cannot generate foreign key references to
tables which are not defined in the same schema is unfortunate (I have
a project with currently 79 tables... ) but a torque limitation.


>2. In "The elegant way" part of the Torque Security Service
>page we have:
> > public class CustomUser extends TorqueUser
>Can you please clarify which class is extending what - I
>assume when I generate my project om I will have CustomUser
>extending BaseCustomUser extending BaseObject.  Which specific
>TorqueUser class is being extended and by which specific class.

This is two-layered.

There is the Torque generated stuff:

DATABASE_USER  ---> DatabaseUser, DatabaseUserPeer, BaseDatabaseUser, 
BaseDatabaseUserPeer

Those classes do _not_ implement the necessary Security Object
Interfaces (like User, Group, Role, Permission). So there is a layer
in between which uses reflection to transfer fields from the database
peers into our security objects. These objects are TorqueUser,
TorqueGroup, TorquePermission, TorqueRole. If you use just the
"normal" fields, you're done here. You configure the Security Service
to return the Torque<xxx> objects and the TorqueSecurityService
automagically maps all the needed information from the Torque
generated peers.

Now, if you want to use custom columns, you must extend the objects implementing
the Security interfaces. These are the Torque<xxx> objects:

package de.intermeta.application.security;

import org.apache.turbine.services.security.torque.TorqueUser;

public class ExtendedUser extends TorqueUser
{
...
}

This is still an object which implements "User". You configure the
SecurityService (!)  to return objects of this type as User objects:

services.SecurityService.user.class = de.intermeta.application.security.ExtendedUser

Note that this is the Security Service itself! Not the TorqueSecurityService!

Your custom user is then responsible to map the additional columns
onto the underlying database peer object.

E.g. if you use 

<table name="CUSTOM_USER" idMethod="idbroker">
[... turbine stuff ...]
    <column name="TELEPHONE" size="32" type="VARCHAR" javaName="Phone" />
</table>

as your database peer, you get

CUSTOM_USER  ---> CustomUser, CustomUserPeer, BaseCustomUser, BaseCustomUserPeer

and you configure the TorqueSecurityService to use this as peer:

services.SecurityService.torque.userPeer.class = CustomUserPeer


public class ExtendedUser extends TorqueUser
{
  public String getPhone()
  {
    return ((CustomUser) getPersistentObj()).getPhone();
  }

getPersistentObj() gets the underlying Torque object, which is a
CustomUser object (because we configured the TSS to use it as peer
objects), so we can cast it. Then we can simply call getPhone() and
return the value.

The "ExtendedUser" is an adapter between the Torque based objects and
the security service objects (which must implement the Security
Service interfaces).

Clearer now? I fixed some bugs in the torque-security-service.xml
docs, too.

        Regards
                Henning

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
[EMAIL PROTECTED]        +49 9131 50 654 0   http://www.intermeta.de/

Java, perl, Solaris, Linux, xSP Consulting, Web Services 
freelance consultant -- Jakarta Turbine Development  -- hero for hire

"Dominate!! Dominate!! Eat your young and aggregate! I have grotty silicon!" 
      -- AOL CD when played backwards  (User Friendly - 200-10-15)

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

Reply via email to