Andreas Hartmann wrote:
Jörn Nettingsmeier wrote:
as a java exercise, i hacked together an alternate version that uses an abstract class AbstractChangePassword that has all the common features, and two derived classes ChangePassword and ChangePasswordAdmin that each add their own extensions. (i chose to do it this way because each of these classes has features that the other hasn't, so there was no obvious way to do it with inheritance.)

This sounds reasonable, and at the first glance your patch looks
very good. Maybe it would make sense to make

  AbstractChangePassword.getUser()

abstract. ChangePassword.getUser() would just return the currently
logged-in user, and AdminChangePassword() would return the user
determined by the userId parameter. WDYT?

i tried it, but then it seemed better to have a variable
  private User user
that defaults to null in AbstractChangePassword, and to set it to the current user in the constuctor of ChangePassword. otherwise the code to determine the current user would be called many times...

a patch is attached, but it does not work, since i'm still stuck with another problem: i want the AbstractChangePassword to initialize "user" with the userId of the currently logged in user, but i can't seem to find out where to get that kind of information... i tried
  Map objectModel = ContextHelper.getObjectModel(getContext());
  Request request = ObjectModelHelper.getRequest(objectModel);
  this.user = Identity.getIdentity(request.getSession(true)).getUser();
but that gives an npe since getContext returns null.

Strange, the same code is used in other usecases ...

BTW, an easier way to get the currently logged-in user from a usecase is:

  User user = getSession().getIdentity().getUser();

the same problem. there seems to be a clash:

compile-src:
Compiling 2 source files to /build/lenya-1_4_X/build/lenya/api
/build/lenya-1_4_X/src/java/org/apache/lenya/cms/ac/usecases/ChangePassword.java:32: incompatible types
found   : org.apache.lenya.cms.repository.Session
required: org.apache.cocoon.environment.Session
       Session session = getSession();
                                   ^
however, the session interface does not define a getSession method. i'm confused....

any hints?




--
"Open source takes the bullshit out of software."
        - Charles Ferguson on TechnologyReview.com

--
Jörn Nettingsmeier, EDV-Administrator
Institut für Politikwissenschaft
Universität Duisburg-Essen, Standort Duisburg
Mail: [EMAIL PROTECTED], Telefon: 0203/379-2736

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

Reply via email to