You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Kenny Smith <ke...@journalscape.com> on 2002/10/31 08:29:54 UTC

App to Update User Data?

Hi all,

I'm trying to build a web app so that my users can login and change their
user passwords, so I'm trying to figure out the best way to go about
updating the table.

I figured I could either a) use the DigestUtil to encode the password and
then do my own SQL to update the user table, or I could b) use the existing
James objects to interface with the database.

Option B sounds best to me, so I went digging. I'll explain more below, but
the roadblock that I'm stopped at is... I can't find the
RemoteManagerHandlerConfigurationDataImpl class.

This is how I got there (tell me if I'm approaching this poorly):

I looked in the RemoteManagerHandler to see how it added users, and found
that it interacts with a UsersRepository (an instance of
JamesUsersJdbcRepository in my case). I looked up the UsersRespository
interface and found an updateUser(User) method, which appears to be exactly
what I'm looking for.

So, I need to get an instance of the UsersRepository, and found that it is
fetched from getUsersRepository() in an instance of a
RemoteManagerHandlerConfigurationData which is actually an instance of
RemoteManagerHandlerConfigurationDataImpl.

RemoteManager gets one by simply calling the constructor, I'm hoping that
all I have to do is call the constructor on it too, but I can't find the
source file anywhere to peek inside and see what it's doing.

As always, any pointers to docs or direct help appreciated,

Kenny Smith
JournalScape.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: App to Update User Data?

Posted by "Peter M. Goldstein" <pe...@yahoo.com>.
Kenny,

> I'm trying to build a web app so that my users can login and change
their
> user passwords, so I'm trying to figure out the best way to go about
> updating the table.
> 
> I figured I could either a) use the DigestUtil to encode the password
and
> then do my own SQL to update the user table, or I could b) use the
> existing
> James objects to interface with the database.
> 
> Option B sounds best to me, so I went digging. I'll explain more
below,
> but
> the roadblock that I'm stopped at is... I can't find the
> RemoteManagerHandlerConfigurationDataImpl class.
> 
> This is how I got there (tell me if I'm approaching this poorly):

I don't think this is quite the right approach.  Might I suggest that
you read a bit more of the Avalon docs before you try and write an app
using the Avalon components.  It will probably save you quite a lot of
grief.

A discussion of the Avalon lifecycle can be found here:

http://jakarta.apache.org/avalon/framework/reference-the-lifecycle.html
 
> I looked in the RemoteManagerHandler to see how it added users, and
found
> that it interacts with a UsersRepository (an instance of
> JamesUsersJdbcRepository in my case). I looked up the UsersRespository
> interface and found an updateUser(User) method, which appears to be
> exactly
> what I'm looking for.
> 
> So, I need to get an instance of the UsersRepository, and found that
it is
> fetched from getUsersRepository() in an instance of a
> RemoteManagerHandlerConfigurationData which is actually an instance of
> RemoteManagerHandlerConfigurationDataImpl.
> 
> RemoteManager gets one by simply calling the constructor, I'm hoping
that
> all I have to do is call the constructor on it too, but I can't find
the
> source file anywhere to peek inside and see what it's doing.

You're missing a key step here.  RemoteManagerHandlerConfigurationImpl
is an inner class of RemoteManager.  You definitely shouldn't be trying
to instantiate it - that would be a very bad idea.  In fact, all
RemoteManagerHandlerConfigurationImpl's getUsersRepository() method does
is return the UsersRepository that was obtained in the compose lifecycle
method of RemoteManager.  So the logic expressed in the compose() method
of RemoteManager is what you should be looking at.

There is some discussion of Composable on the page referenced above,
even though it has been deprecated in favor of Serviceable.  The basic
idea behind both Composable and Serviceable is that classes that
implemented these interfaces can lookup other components that are
managed by the container.

In the RemoteManager class, RemoteManager looks up the UsersStore
implementation, which manages the list of repositories.  The relevant
code fragment is:

    public void compose( final ComponentManager componentManager )
        throws ComponentException {

...
        usersStore = (UsersStore)componentManager.
            lookup( "org.apache.james.services.UsersStore" );
        users = usersStore.getRepository("LocalUsers");

...
        }
    }

This is how one gets ahold of components and children of components -
not by direct instantiation.  Instantiation is left to the container.

--Peter



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>