portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dave Carlson" <dcarl...@ontogenics.com>
Subject testing the User object values
Date Fri, 03 Aug 2001 17:48:55 GMT
As a way to understand the template mechanism in Jetspeed, and the database
persistence provided by Turbine, I created a simple test JSP template that
others may find helpful.

The database tables include on OBJECTDATA field, whose content was a mystery
to me.  After reviewing Turbine code, I understood that any attribute/value
pairs could be assigned to a User and if the attribute did not match an column
name in the database table schema, then it was serialized into a Hashtable in
OBJECTDATA.  But I still did not know *what* was in that blob value.

The following simple JSP page dumps all attributes of a User retrieved from
the database, regardless of whether they are from the table columns or
deserialized from the OBJECTDATA.  (This is not recommended coding style for
production JSP!!!  Just a quick hack that is easy to modify and test without
recompiling a servlet and restarting tomcat.)

Two attributes are extracted from the blob:  _access_counter and LAST_LOGIN.
Now, LAST_LOGIN should be in a User table column, but it's not.  This test
uncovered a SQL script error in all database variations included with
Jetspeed.  All 6 turbine-*.sql scripts include TURBINE_USER.LASTLOGIN, where
they should have TURBINE_USER.LAST_LOGIN.  I checked the turbine tdk 2.1, and
the sql scripts contained there are correct.

If you modify this column name in the database, then subsequent accesses to
Jetspeed will correctly populate the LAST_LOGIN column, which can be viewed
via a simple DB select.

I still have not figured out why the CREATED and MODIFIED columns are not
populated in the database...

Hope this is helpful,
  Dave Carlson

Browser URL:  http://192.168.1.5/jetspeed/portal/template/TestAccount.jsp
(obviously, replace your own host:port)

Results:
--------------------------------
User persistent data

LOGIN_NAME admin
PASSWORD_VALUE jetspeed
_access_counter 7
FIRST_NAME Raphael
LAST_LOGIN Fri Aug 03 09:23:34 MDT 2001
CONFIRM_VALUE CONFIRMED
LAST_NAME Admin
EMAIL raphael@apache.org
------------------------------

Save this JSP to: /WEB-INF/templates/jsp/screens/html/TestAccount.jsp

-------------------------
<%@ taglib uri='/WEB-INF/templates/jsp/tld/template.tld' prefix='jetspeed' %>

<%@ page import = "org.apache.turbine.util.RunData" %>
<%@ page import = "org.apache.turbine.om.security.User" %>

<div align="left">
  <h2>User persistent data</h2>

  <table cellpadding="2" cellspacing="0" border="1">

<%
    User user = ((RunData)request.getAttribute("rundata")).getUser();
    java.util.Hashtable attrs = user.getPermStorage();
    java.util.Enumeration enum = attrs.keys();
    while( enum.hasMoreElements() ) {
        String name = enum.nextElement().toString();
        Object value = attrs.get(name);

        %>
            <tr>
              <td><%=name%></td><td><%=value%></td>
            </tr>
        <%
    }
%>

  </table>
</div>
--------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message