Modified: 
turbine/core/trunk/src/java/org/apache/turbine/om/security/DefaultUserImpl.java
URL: 
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/om/security/DefaultUserImpl.java?rev=1812628&r1=1812627&r2=1812628&view=diff
==============================================================================
--- 
turbine/core/trunk/src/java/org/apache/turbine/om/security/DefaultUserImpl.java 
(original)
+++ 
turbine/core/trunk/src/java/org/apache/turbine/om/security/DefaultUserImpl.java 
Thu Oct 19 12:34:25 2017
@@ -1,755 +1,755 @@
-package org.apache.turbine.om.security;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintWriter;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import javax.servlet.http.HttpSessionBindingEvent;
-
-import org.apache.fulcrum.security.model.turbine.entity.TurbineUser;
-import org.apache.fulcrum.security.model.turbine.entity.TurbineUserGroupRole;
-import org.apache.turbine.services.TurbineServices;
-import org.apache.turbine.services.security.SecurityService;
-import org.apache.turbine.util.ObjectUtils;
-
-/**
- * This is the Default user implementation. It is a wrapper around
- * a TurbineUser object
- *
- * @author <a href="mailto:[email protected]";>Thomas Vandahl</a>
- * @version $Id: TorqueUser.java 1199856 2011-11-09 17:06:04Z tv $
- */
-
-public class DefaultUserImpl implements User, TurbineUserDelegate
-{
-    /** Serial version */
-    private static final long serialVersionUID = -1866504873085624111L;
-
-    /** The date on which the user last accessed the application. */
-    private Date lastAccessDate = null;
-
-    /** This is data that will survive a servlet engine restart. */
-    private Map<String, Object> permStorage = null;
-
-    /** This is data that will not survive a servlet engine restart. */
-    private Map<String, Object> tempStorage = null;
-
-    /** The Fulcrum user instance to delegate to */
-    private TurbineUser userDelegate = null;
-
-    /**
-     * Constructor
-     *
-     * @param user the user object to wrap
-     */
-    public DefaultUserImpl(TurbineUser user)
-    {
-        super();
-        this.userDelegate = user;
-        setCreateDate(new Date());
-        tempStorage = new HashMap<String, Object>(10);
-        setHasLoggedIn(Boolean.FALSE);
-    }
-
-    /**
-     * Implement this method if you wish to be notified when the User
-     * has been Bound to the session.
-     *
-     * @param hsbe Indication of value/session binding.
-     */
-    @Override
-    public void valueBound(HttpSessionBindingEvent hsbe)
-    {
-        // Currently we have no need for this method.
-    }
-
-    /**
-     * Implement this method if you wish to be notified when the User
-     * has been Unbound from the session.
-     *
-     * @param hsbe Indication of value/session unbinding.
-     */
-    @Override
-    public void valueUnbound(HttpSessionBindingEvent hsbe)
-    {
-        try
-        {
-            if (hasLoggedIn())
-            {
-                SecurityService securityService = 
(SecurityService)TurbineServices.getInstance().getService(SecurityService.SERVICE_NAME);
-                securityService.saveOnSessionUnbind(this);
-            }
-        }
-        catch (Exception e)
-        {
-            //Log.error("TorqueUser.valueUnbound(): " + e.getMessage(), e);
-
-            // To prevent messages being lost in case the logging system
-            // goes away before sessions get unbound on servlet container
-            // shutdown, print the stacktrace to the container's console.
-            ByteArrayOutputStream ostr = new ByteArrayOutputStream();
-            e.printStackTrace(new PrintWriter(ostr, true));
-            String stackTrace = ostr.toString();
-            System.out.println(stackTrace);
-        }
-    }
-
-    /**
-     * Get the Name of the SecurityEntity.
-     *
-     * @return The Name of the SecurityEntity.
-     */
-    @Override
-    public String getName()
-    {
-        return userDelegate.getName();
-    }
-
-    /**
-     * Sets the Name of the SecurityEntity.
-     *
-     * @param name
-     *            Name of the SecurityEntity.
-     */
-    @Override
-    public void setName(String name)
-    {
-        userDelegate.setName(name);
-    }
-
-    /**
-     * Get the Id of the SecurityEntity.
-     *
-     * @return The Id of the SecurityEntity.
-     */
-    @Override
-    public Object getId()
-    {
-        return userDelegate.getId();
-    }
-
-    /**
-     * Sets the Id of the SecurityEntity.
-     *
-     * @param id
-     *            The new Id of the SecurityEntity
-     */
-    @Override
-    public void setId(Object id)
-    {
-        userDelegate.setId(id);
-    }
-
-    /**
-     * Returns the user's password. This method should not be used by
-     * the application directly, because it's meaning depends upon
-     * the implementation of UserManager that manages this particular
-     * user object. Some implementations will use this attribute for
-     * storing a password encrypted in some way, other will not use
-     * it at all, when user entered password is presented to some external
-     * authority (like NT domain controller) to validate it.
-     * See also {@link 
org.apache.turbine.services.security.UserManager#authenticate(User,String)}.
-     *
-     * @return A String with the password for the user.
-     */
-    @Override
-    public String getPassword()
-    {
-        return userDelegate.getPassword();
-    }
-
-    /**
-     * Set password. Application should not use this method
-     * directly, see {@link #getPassword()}.
-     * See also {@link 
org.apache.turbine.services.security.UserManager#changePassword(User,String,String)}.
-     *
-     * @param password The new password.
-     */
-    @Override
-    public void setPassword(String password)
-    {
-        userDelegate.setPassword(password);
-    }
-
-    /**
-     * Returns the first name for this user.
-     *
-     * @return A String with the user's first name.
-     */
-
-    @Override
-    public String getFirstName()
-    {
-        return userDelegate.getFirstName();
-    }
-
-    /**
-     * Sets the first name for this user.
-     *
-     * @param firstName User's first name.
-     */
-    @Override
-    public void setFirstName(String firstName)
-    {
-        userDelegate.setFirstName(firstName);
-    }
-
-    /**
-     * Returns the last name for this user.
-     *
-     * @return A String with the user's last name.
-     */
-    @Override
-    public String getLastName()
-    {
-        return userDelegate.getLastName();
-    }
-
-    /**
-     * Sets the last name for this user.
-     *
-     * @param lastName User's last name.
-     */
-    @Override
-    public void setLastName(String lastName)
-    {
-        userDelegate.setLastName(lastName);
-    }
-
-    /**
-     * Returns the email address for this user.
-     *
-     * @return A String with the user's email address.
-     */
-    @Override
-    public String getEmail()
-    {
-        return userDelegate.getEmail();
-    }
-
-    /**
-     * Sets the email address.
-     *
-     * @param address The email address.
-     */
-    @Override
-    public void setEmail(String address)
-    {
-        userDelegate.setEmail(address);
-    }
-
-    /**
-     * Returns the value of the objectdata for this user.
-     * Objectdata is a storage area used
-     * to store the permanent storage table from the User
-     * object.
-     *
-     * @return The bytes in the objectdata for this user
-     */
-    @Override
-    public byte[] getObjectdata()
-    {
-        return userDelegate.getObjectdata();
-    }
-
-    /**
-     * Sets the value of the objectdata for the user
-     *
-     * @param objectdata The new permanent storage for the user
-     */
-    @Override
-    public void setObjectdata(byte[] objectdata)
-    {
-        userDelegate.setObjectdata(objectdata);
-    }
-
-    /**
-     * Get the User/Group/Role set associated with this entity
-     *
-     * @return a set of User/Group/Role relations
-     */
-    @Override
-    public <T extends TurbineUserGroupRole> Set<T> getUserGroupRoleSet()
-    {
-        return userDelegate.getUserGroupRoleSet();
-    }
-
-    /**
-     * Set the User/Group/Role set associated with this entity
-     *
-     * @param userGroupRoleSet
-     *            a set of User/Group/Role relations
-     */
-    @Override
-    public <T extends TurbineUserGroupRole> void setUserGroupRoleSet(Set<T> 
userGroupRoleSet)
-    {
-        userDelegate.setUserGroupRoleSet(userGroupRoleSet);
-    }
-
-    /**
-     * Add a User/Group/Role relation to this entity
-     *
-     * @param userGroupRole
-     *            a User/Group/Role relation to add
-     */
-    @Override
-    public void addUserGroupRole(TurbineUserGroupRole userGroupRole)
-    {
-        userDelegate.addUserGroupRole(userGroupRole);
-    }
-
-    /**
-     * Remove a User/Group/Role relation from this entity
-     *
-     * @param userGroupRole
-     *            a User/Group/Role relation to remove
-     */
-    @Override
-    public void removeUserGroupRole(TurbineUserGroupRole userGroupRole)
-    {
-        userDelegate.removeUserGroupRole(userGroupRole);
-    }
-
-    /**
-     * Gets the access counter for a user from perm storage.
-     *
-     * @return The access counter for the user.
-     */
-    @Override
-    public int getAccessCounter()
-    {
-        try
-        {
-            return ((Integer) getPerm(User.ACCESS_COUNTER)).intValue();
-        }
-        catch (Exception e)
-        {
-            return 0;
-        }
-    }
-
-    /**
-     * Gets the access counter for a user during a session.
-     *
-     * @return The access counter for the user for the session.
-     */
-    @Override
-    public int getAccessCounterForSession()
-    {
-        try
-        {
-            return ((Integer) getTemp(User.SESSION_ACCESS_COUNTER)).intValue();
-        }
-        catch (Exception e)
-        {
-            return 0;
-        }
-    }
-
-    /**
-     * Increments the permanent hit counter for the user.
-     */
-    @Override
-    public void incrementAccessCounter()
-    {
-        // Ugh. Race city, here I come...
-        setAccessCounter(getAccessCounter() + 1);
-    }
-
-    /**
-     * Increments the session hit counter for the user.
-     */
-    @Override
-    public void incrementAccessCounterForSession()
-    {
-        setAccessCounterForSession(getAccessCounterForSession() + 1);
-    }
-
-    /**
-     * Sets the access counter for a user, saved in perm storage.
-     *
-     * @param cnt The new count.
-     */
-    @Override
-    public void setAccessCounter(int cnt)
-    {
-        setPerm(User.ACCESS_COUNTER, Integer.valueOf(cnt));
-    }
-
-    /**
-     * Sets the session access counter for a user, saved in temp
-     * storage.
-     *
-     * @param cnt The new count.
-     */
-    @Override
-    public void setAccessCounterForSession(int cnt)
-    {
-        setTemp(User.SESSION_ACCESS_COUNTER, Integer.valueOf(cnt));
-    }
-
-    /**
-     * Gets the last access date for this User.  This is the last time
-     * that the user object was referenced.
-     *
-     * @return A Java Date with the last access date for the user.
-     */
-    @Override
-    public java.util.Date getLastAccessDate()
-    {
-        if (lastAccessDate == null)
-        {
-            setLastAccessDate();
-        }
-        return lastAccessDate;
-    }
-
-    /**
-     * Sets the last access date for this User. This is the last time
-     * that the user object was referenced.
-     */
-    @Override
-    public void setLastAccessDate()
-    {
-        lastAccessDate = new java.util.Date();
-    }
-
-    /**
-     * Returns the permanent storage. This is implemented
-     * as a Map
-     *
-     * @return A Map.
-     */
-    @Override
-    public Map<String, Object> getPermStorage()
-    {
-        if (permStorage == null)
-        {
-            byte [] objectdata = getObjectdata();
-
-            if (objectdata != null)
-            {
-                permStorage = ObjectUtils.deserialize(objectdata);
-            }
-
-            if (permStorage == null)
-            {
-                permStorage = new HashMap<String, Object>();
-            }
-        }
-
-        return permStorage;
-    }
-
-    /**
-     * This should only be used in the case where we want to make the
-     * data persistent.
-     *
-     * @param permStorage A Map.
-     */
-    @Override
-    public void setPermStorage(Map<String, Object> permStorage)
-    {
-        if (permStorage != null)
-        {
-            this.permStorage = permStorage;
-        }
-    }
-
-    /**
-     * Returns the temporary storage. This is implemented
-     * as a Map
-     *
-     * @return A Map.
-     */
-    @Override
-    public Map<String, Object> getTempStorage()
-    {
-        if (tempStorage == null)
-        {
-            tempStorage = new HashMap<String, Object>();
-        }
-        return tempStorage;
-    }
-
-    /**
-     * This should only be used in the case where we want to save the
-     * data to the database.
-     *
-     * @param tempStorage A Map.
-     */
-    @Override
-    public void setTempStorage(Map<String, Object> tempStorage)
-    {
-        if (tempStorage != null)
-        {
-            this.tempStorage = tempStorage;
-        }
-    }
-
-    /**
-     * Get an object from permanent storage.
-     *
-     * @param name The object's name.
-     * @return An Object with the given name.
-     */
-    @Override
-    public Object getPerm(String name)
-    {
-        return getPermStorage().get(name);
-    }
-
-    /**
-     * Get an object from permanent storage; return default if value
-     * is null.
-     *
-     * @param name The object's name.
-     * @param def A default value to return.
-     * @return An Object with the given name.
-     */
-    @Override
-    public Object getPerm(String name, Object def)
-    {
-        try
-        {
-            Object val = getPermStorage().get(name);
-            return (val == null ? def : val);
-        }
-        catch (Exception e)
-        {
-            return def;
-        }
-    }
-
-    /**
-     * Put an object into permanent storage.
-     *
-     * @param name The object's name.
-     * @param value The object.
-     */
-    @Override
-    public void setPerm(String name, Object value)
-    {
-        getPermStorage().put(name, value);
-    }
-
-    /**
-     * Get an object from temporary storage.
-     *
-     * @param name The object's name.
-     * @return An Object with the given name.
-     */
-    @Override
-    public Object getTemp(String name)
-    {
-        return getTempStorage().get(name);
-    }
-
-    /**
-     * Get an object from temporary storage; return default if value
-     * is null.
-     *
-     * @param name The object's name.
-     * @param def A default value to return.
-     * @return An Object with the given name.
-     */
-    @Override
-    public Object getTemp(String name, Object def)
-    {
-        Object val;
-        try
-        {
-            val = getTempStorage().get(name);
-            if (val == null)
-            {
-                val = def;
-            }
-        }
-        catch (Exception e)
-        {
-            val = def;
-        }
-        return val;
-    }
-
-    /**
-     * Put an object into temporary storage.
-     *
-     * @param name The object's name.
-     * @param value The object.
-     */
-    @Override
-    public void setTemp(String name, Object value)
-    {
-        getTempStorage().put(name, value);
-    }
-
-    /**
-     * Remove an object from temporary storage and return the object.
-     *
-     * @param name The name of the object to remove.
-     * @return An Object.
-     */
-    @Override
-    public Object removeTemp(String name)
-    {
-        return getTempStorage().remove(name);
-    }
-
-    /**
-     * Returns the confirm value of the user
-     *
-     * @return The confirm value of the user
-     */
-    @Override
-    public String getConfirmed()
-    {
-        return (String) getPerm(User.CONFIRM_VALUE);
-    }
-
-    /**
-     * Sets the new confirm value of the user
-     *
-     * @param confirm The new confirm value of the user
-     */
-    @Override
-    public void setConfirmed(String confirm)
-    {
-        setPerm(User.CONFIRM_VALUE, confirm);
-    }
-
-    /**
-     * Returns the creation date of the user
-     *
-     * @return The creation date of the user
-     */
-    @Override
-    public java.util.Date getCreateDate()
-    {
-        return (java.util.Date)getPerm(CREATE_DATE, new java.util.Date());
-    }
-
-    /**
-     * Sets the new creation date of the user
-     *
-     * @param createDate The new creation date of the user
-     */
-    @Override
-    public void setCreateDate(java.util.Date createDate)
-    {
-        setPerm(CREATE_DATE, createDate);
-    }
-
-    /**
-     * Returns the date of the last login of the user
-     *
-     * @return The date of the last login of the user
-     */
-    @Override
-    public java.util.Date getLastLogin()
-    {
-        return (java.util.Date) getPerm(User.LAST_LOGIN);
-    }
-
-    /**
-     * Sets the new date of the last login of the user
-     *
-     * @param lastLogin The new the date of the last login of the user
-     */
-    @Override
-    public void setLastLogin(java.util.Date lastLogin)
-    {
-        setPerm(User.LAST_LOGIN, lastLogin);
-    }
-
-    /**
-     * The user is considered logged in if they have not timed out.
-     *
-     * @return Whether the user has logged in.
-     */
-    @Override
-    public boolean hasLoggedIn()
-    {
-        Boolean loggedIn = (Boolean) getTemp(User.HAS_LOGGED_IN);
-        return (loggedIn != null && loggedIn.booleanValue());
-    }
-
-    /**
-     * This sets whether or not someone has logged in.  hasLoggedIn()
-     * returns this value.
-     *
-     * @param value Whether someone has logged in or not.
-     */
-    @Override
-    public void setHasLoggedIn(Boolean value)
-    {
-        setTemp(User.HAS_LOGGED_IN, value);
-    }
-
-    /**
-     * This method reports whether or not the user has been confirmed
-     * in the system by checking the User.CONFIRM_VALUE
-     * column in the users record to see if it is equal to
-     * User.CONFIRM_DATA.
-     *
-     * @return True if the user has been confirmed.
-     */
-    @Override
-    public boolean isConfirmed()
-    {
-        String value = getConfirmed();
-        return (value != null && value.equals(User.CONFIRM_DATA));
-    }
-
-    /**
-     * Updates the last login date in the database.
-     *
-     * @throws Exception A generic exception.
-     */
-    @Override
-    public void updateLastLogin()
-        throws Exception
-    {
-        setLastLogin(new java.util.Date());
-    }
-
-    /* (non-Javadoc)
-        * @see org.apache.turbine.om.security.UserDelegate#getUserDelegate()
-        */
-    @Override
-       public TurbineUser getUserDelegate()
-    {
-        return userDelegate;
-    }
-
-    /* (non-Javadoc)
-        * @see 
org.apache.turbine.om.security.UserDelegate#setUserDelegate(org.apache.fulcrum.security.model.turbine.entity.TurbineUser)
-        */
-    @Override
-       public void setUserDelegate(TurbineUser userDelegate)
-    {
-        this.userDelegate = userDelegate;
-    }
-}
+package org.apache.turbine.om.security;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.http.HttpSessionBindingEvent;
+
+import org.apache.fulcrum.security.model.turbine.entity.TurbineUser;
+import org.apache.fulcrum.security.model.turbine.entity.TurbineUserGroupRole;
+import org.apache.turbine.services.TurbineServices;
+import org.apache.turbine.services.security.SecurityService;
+import org.apache.turbine.util.ObjectUtils;
+
+/**
+ * This is the Default user implementation. It is a wrapper around
+ * a TurbineUser object
+ *
+ * @author <a href="mailto:[email protected]";>Thomas Vandahl</a>
+ * @version $Id: TorqueUser.java 1199856 2011-11-09 17:06:04Z tv $
+ */
+
+public class DefaultUserImpl implements User, TurbineUserDelegate
+{
+    /** Serial version */
+    private static final long serialVersionUID = -1866504873085624111L;
+
+    /** The date on which the user last accessed the application. */
+    private Date lastAccessDate = null;
+
+    /** This is data that will survive a servlet engine restart. */
+    private Map<String, Object> permStorage = null;
+
+    /** This is data that will not survive a servlet engine restart. */
+    private Map<String, Object> tempStorage = null;
+
+    /** The Fulcrum user instance to delegate to */
+    private TurbineUser userDelegate = null;
+
+    /**
+     * Constructor
+     *
+     * @param user the user object to wrap
+     */
+    public DefaultUserImpl(TurbineUser user)
+    {
+        super();
+        setUserDelegate( user );;
+        setCreateDate(new Date());
+        tempStorage = new HashMap<String, Object>(10);
+        setHasLoggedIn(Boolean.FALSE);
+    }
+
+    /**
+     * Implement this method if you wish to be notified when the User
+     * has been Bound to the session.
+     *
+     * @param hsbe Indication of value/session binding.
+     */
+    @Override
+    public void valueBound(HttpSessionBindingEvent hsbe)
+    {
+        // Currently we have no need for this method.
+    }
+
+    /**
+     * Implement this method if you wish to be notified when the User
+     * has been Unbound from the session.
+     *
+     * @param hsbe Indication of value/session unbinding.
+     */
+    @Override
+    public void valueUnbound(HttpSessionBindingEvent hsbe)
+    {
+        try
+        {
+            if (hasLoggedIn())
+            {
+                SecurityService securityService = 
(SecurityService)TurbineServices.getInstance().getService(SecurityService.SERVICE_NAME);
+                securityService.saveOnSessionUnbind(this);
+            }
+        }
+        catch (Exception e)
+        {
+            //Log.error("TorqueUser.valueUnbound(): " + e.getMessage(), e);
+
+            // To prevent messages being lost in case the logging system
+            // goes away before sessions get unbound on servlet container
+            // shutdown, print the stacktrace to the container's console.
+            ByteArrayOutputStream ostr = new ByteArrayOutputStream();
+            e.printStackTrace(new PrintWriter(ostr, true));
+            String stackTrace = ostr.toString();
+            System.out.println(stackTrace);
+        }
+    }
+
+    /**
+     * Get the Name of the SecurityEntity.
+     *
+     * @return The Name of the SecurityEntity.
+     */
+    @Override
+    public String getName()
+    {
+        return userDelegate.getName();
+    }
+
+    /**
+     * Sets the Name of the SecurityEntity.
+     *
+     * @param name
+     *            Name of the SecurityEntity.
+     */
+    @Override
+    public void setName(String name)
+    {
+        userDelegate.setName(name);
+    }
+
+    /**
+     * Get the Id of the SecurityEntity.
+     *
+     * @return The Id of the SecurityEntity.
+     */
+    @Override
+    public Object getId()
+    {
+        return userDelegate.getId();
+    }
+
+    /**
+     * Sets the Id of the SecurityEntity.
+     *
+     * @param id
+     *            The new Id of the SecurityEntity
+     */
+    @Override
+    public void setId(Object id)
+    {
+        userDelegate.setId(id);
+    }
+
+    /**
+     * Returns the user's password. This method should not be used by
+     * the application directly, because it's meaning depends upon
+     * the implementation of UserManager that manages this particular
+     * user object. Some implementations will use this attribute for
+     * storing a password encrypted in some way, other will not use
+     * it at all, when user entered password is presented to some external
+     * authority (like NT domain controller) to validate it.
+     * See also {@link 
org.apache.turbine.services.security.UserManager#authenticate(User,String)}.
+     *
+     * @return A String with the password for the user.
+     */
+    @Override
+    public String getPassword()
+    {
+        return userDelegate.getPassword();
+    }
+
+    /**
+     * Set password. Application should not use this method
+     * directly, see {@link #getPassword()}.
+     * See also {@link 
org.apache.turbine.services.security.UserManager#changePassword(User,String,String)}.
+     *
+     * @param password The new password.
+     */
+    @Override
+    public void setPassword(String password)
+    {
+        userDelegate.setPassword(password);
+    }
+
+    /**
+     * Returns the first name for this user.
+     *
+     * @return A String with the user's first name.
+     */
+
+    @Override
+    public String getFirstName()
+    {
+        return userDelegate.getFirstName();
+    }
+
+    /**
+     * Sets the first name for this user.
+     *
+     * @param firstName User's first name.
+     */
+    @Override
+    public void setFirstName(String firstName)
+    {
+        userDelegate.setFirstName(firstName);
+    }
+
+    /**
+     * Returns the last name for this user.
+     *
+     * @return A String with the user's last name.
+     */
+    @Override
+    public String getLastName()
+    {
+        return userDelegate.getLastName();
+    }
+
+    /**
+     * Sets the last name for this user.
+     *
+     * @param lastName User's last name.
+     */
+    @Override
+    public void setLastName(String lastName)
+    {
+        userDelegate.setLastName(lastName);
+    }
+
+    /**
+     * Returns the email address for this user.
+     *
+     * @return A String with the user's email address.
+     */
+    @Override
+    public String getEmail()
+    {
+        return userDelegate.getEmail();
+    }
+
+    /**
+     * Sets the email address.
+     *
+     * @param address The email address.
+     */
+    @Override
+    public void setEmail(String address)
+    {
+        userDelegate.setEmail(address);
+    }
+
+    /**
+     * Returns the value of the objectdata for this user.
+     * Objectdata is a storage area used
+     * to store the permanent storage table from the User
+     * object.
+     *
+     * @return The bytes in the objectdata for this user
+     */
+    @Override
+    public byte[] getObjectdata()
+    {
+        return userDelegate.getObjectdata();
+    }
+
+    /**
+     * Sets the value of the objectdata for the user
+     *
+     * @param objectdata The new permanent storage for the user
+     */
+    @Override
+    public void setObjectdata(byte[] objectdata)
+    {
+        userDelegate.setObjectdata(objectdata);
+    }
+
+    /**
+     * Get the User/Group/Role set associated with this entity
+     *
+     * @return a set of User/Group/Role relations
+     */
+    @Override
+    public <T extends TurbineUserGroupRole> Set<T> getUserGroupRoleSet()
+    {
+        return userDelegate.getUserGroupRoleSet();
+    }
+
+    /**
+     * Set the User/Group/Role set associated with this entity
+     *
+     * @param userGroupRoleSet
+     *            a set of User/Group/Role relations
+     */
+    @Override
+    public <T extends TurbineUserGroupRole> void setUserGroupRoleSet(Set<T> 
userGroupRoleSet)
+    {
+        userDelegate.setUserGroupRoleSet(userGroupRoleSet);
+    }
+
+    /**
+     * Add a User/Group/Role relation to this entity
+     *
+     * @param userGroupRole
+     *            a User/Group/Role relation to add
+     */
+    @Override
+    public void addUserGroupRole(TurbineUserGroupRole userGroupRole)
+    {
+        userDelegate.addUserGroupRole(userGroupRole);
+    }
+
+    /**
+     * Remove a User/Group/Role relation from this entity
+     *
+     * @param userGroupRole
+     *            a User/Group/Role relation to remove
+     */
+    @Override
+    public void removeUserGroupRole(TurbineUserGroupRole userGroupRole)
+    {
+        userDelegate.removeUserGroupRole(userGroupRole);
+    }
+
+    /**
+     * Gets the access counter for a user from perm storage.
+     *
+     * @return The access counter for the user.
+     */
+    @Override
+    public int getAccessCounter()
+    {
+        try
+        {
+            return ((Integer) getPerm(User.ACCESS_COUNTER)).intValue();
+        }
+        catch (Exception e)
+        {
+            return 0;
+        }
+    }
+
+    /**
+     * Gets the access counter for a user during a session.
+     *
+     * @return The access counter for the user for the session.
+     */
+    @Override
+    public int getAccessCounterForSession()
+    {
+        try
+        {
+            return ((Integer) getTemp(User.SESSION_ACCESS_COUNTER)).intValue();
+        }
+        catch (Exception e)
+        {
+            return 0;
+        }
+    }
+
+    /**
+     * Increments the permanent hit counter for the user.
+     */
+    @Override
+    public void incrementAccessCounter()
+    {
+        // Ugh. Race city, here I come...
+        setAccessCounter(getAccessCounter() + 1);
+    }
+
+    /**
+     * Increments the session hit counter for the user.
+     */
+    @Override
+    public void incrementAccessCounterForSession()
+    {
+        setAccessCounterForSession(getAccessCounterForSession() + 1);
+    }
+
+    /**
+     * Sets the access counter for a user, saved in perm storage.
+     *
+     * @param cnt The new count.
+     */
+    @Override
+    public void setAccessCounter(int cnt)
+    {
+        setPerm(User.ACCESS_COUNTER, Integer.valueOf(cnt));
+    }
+
+    /**
+     * Sets the session access counter for a user, saved in temp
+     * storage.
+     *
+     * @param cnt The new count.
+     */
+    @Override
+    public void setAccessCounterForSession(int cnt)
+    {
+        setTemp(User.SESSION_ACCESS_COUNTER, Integer.valueOf(cnt));
+    }
+
+    /**
+     * Gets the last access date for this User.  This is the last time
+     * that the user object was referenced.
+     *
+     * @return A Java Date with the last access date for the user.
+     */
+    @Override
+    public java.util.Date getLastAccessDate()
+    {
+        if (lastAccessDate == null)
+        {
+            setLastAccessDate();
+        }
+        return lastAccessDate;
+    }
+
+    /**
+     * Sets the last access date for this User. This is the last time
+     * that the user object was referenced.
+     */
+    @Override
+    public void setLastAccessDate()
+    {
+        lastAccessDate = new java.util.Date();
+    }
+
+    /**
+     * Returns the permanent storage. This is implemented
+     * as a Map
+     *
+     * @return A Map.
+     */
+    @Override
+    public Map<String, Object> getPermStorage()
+    {
+        if (permStorage == null)
+        {
+            byte [] objectdata = getObjectdata();
+
+            if (objectdata != null)
+            {
+                permStorage = ObjectUtils.deserialize(objectdata);
+            }
+
+            if (permStorage == null)
+            {
+                permStorage = new HashMap<String, Object>();
+            }
+        }
+
+        return permStorage;
+    }
+
+    /**
+     * This should only be used in the case where we want to make the
+     * data persistent.
+     *
+     * @param permStorage A Map.
+     */
+    @Override
+    public void setPermStorage(Map<String, Object> permStorage)
+    {
+        if (permStorage != null)
+        {
+            this.permStorage = permStorage;
+        }
+    }
+
+    /**
+     * Returns the temporary storage. This is implemented
+     * as a Map
+     *
+     * @return A Map.
+     */
+    @Override
+    public Map<String, Object> getTempStorage()
+    {
+        if (tempStorage == null)
+        {
+            tempStorage = new HashMap<String, Object>();
+        }
+        return tempStorage;
+    }
+
+    /**
+     * This should only be used in the case where we want to save the
+     * data to the database.
+     *
+     * @param tempStorage A Map.
+     */
+    @Override
+    public void setTempStorage(Map<String, Object> tempStorage)
+    {
+        if (tempStorage != null)
+        {
+            this.tempStorage = tempStorage;
+        }
+    }
+
+    /**
+     * Get an object from permanent storage.
+     *
+     * @param name The object's name.
+     * @return An Object with the given name.
+     */
+    @Override
+    public Object getPerm(String name)
+    {
+        return getPermStorage().get(name);
+    }
+
+    /**
+     * Get an object from permanent storage; return default if value
+     * is null.
+     *
+     * @param name The object's name.
+     * @param def A default value to return.
+     * @return An Object with the given name.
+     */
+    @Override
+    public Object getPerm(String name, Object def)
+    {
+        try
+        {
+            Object val = getPermStorage().get(name);
+            return (val == null ? def : val);
+        }
+        catch (Exception e)
+        {
+            return def;
+        }
+    }
+
+    /**
+     * Put an object into permanent storage.
+     *
+     * @param name The object's name.
+     * @param value The object.
+     */
+    @Override
+    public void setPerm(String name, Object value)
+    {
+        getPermStorage().put(name, value);
+    }
+
+    /**
+     * Get an object from temporary storage.
+     *
+     * @param name The object's name.
+     * @return An Object with the given name.
+     */
+    @Override
+    public Object getTemp(String name)
+    {
+        return getTempStorage().get(name);
+    }
+
+    /**
+     * Get an object from temporary storage; return default if value
+     * is null.
+     *
+     * @param name The object's name.
+     * @param def A default value to return.
+     * @return An Object with the given name.
+     */
+    @Override
+    public Object getTemp(String name, Object def)
+    {
+        Object val;
+        try
+        {
+            val = getTempStorage().get(name);
+            if (val == null)
+            {
+                val = def;
+            }
+        }
+        catch (Exception e)
+        {
+            val = def;
+        }
+        return val;
+    }
+
+    /**
+     * Put an object into temporary storage.
+     *
+     * @param name The object's name.
+     * @param value The object.
+     */
+    @Override
+    public void setTemp(String name, Object value)
+    {
+        getTempStorage().put(name, value);
+    }
+
+    /**
+     * Remove an object from temporary storage and return the object.
+     *
+     * @param name The name of the object to remove.
+     * @return An Object.
+     */
+    @Override
+    public Object removeTemp(String name)
+    {
+        return getTempStorage().remove(name);
+    }
+
+    /**
+     * Returns the confirm value of the user
+     *
+     * @return The confirm value of the user
+     */
+    @Override
+    public String getConfirmed()
+    {
+        return (String) getPerm(User.CONFIRM_VALUE);
+    }
+
+    /**
+     * Sets the new confirm value of the user
+     *
+     * @param confirm The new confirm value of the user
+     */
+    @Override
+    public void setConfirmed(String confirm)
+    {
+        setPerm(User.CONFIRM_VALUE, confirm);
+    }
+
+    /**
+     * Returns the creation date of the user
+     *
+     * @return The creation date of the user
+     */
+    @Override
+    public java.util.Date getCreateDate()
+    {
+        return (java.util.Date)getPerm(CREATE_DATE, new java.util.Date());
+    }
+
+    /**
+     * Sets the new creation date of the user
+     *
+     * @param createDate The new creation date of the user
+     */
+    @Override
+    public void setCreateDate(java.util.Date createDate)
+    {
+        setPerm(CREATE_DATE, createDate);
+    }
+
+    /**
+     * Returns the date of the last login of the user
+     *
+     * @return The date of the last login of the user
+     */
+    @Override
+    public java.util.Date getLastLogin()
+    {
+        return (java.util.Date) getPerm(User.LAST_LOGIN);
+    }
+
+    /**
+     * Sets the new date of the last login of the user
+     *
+     * @param lastLogin The new the date of the last login of the user
+     */
+    @Override
+    public void setLastLogin(java.util.Date lastLogin)
+    {
+        setPerm(User.LAST_LOGIN, lastLogin);
+    }
+
+    /**
+     * The user is considered logged in if they have not timed out.
+     *
+     * @return Whether the user has logged in.
+     */
+    @Override
+    public boolean hasLoggedIn()
+    {
+        Boolean loggedIn = (Boolean) getTemp(User.HAS_LOGGED_IN);
+        return (loggedIn != null && loggedIn.booleanValue());
+    }
+
+    /**
+     * This sets whether or not someone has logged in.  hasLoggedIn()
+     * returns this value.
+     *
+     * @param value Whether someone has logged in or not.
+     */
+    @Override
+    public void setHasLoggedIn(Boolean value)
+    {
+        setTemp(User.HAS_LOGGED_IN, value);
+    }
+
+    /**
+     * This method reports whether or not the user has been confirmed
+     * in the system by checking the User.CONFIRM_VALUE
+     * column in the users record to see if it is equal to
+     * User.CONFIRM_DATA.
+     *
+     * @return True if the user has been confirmed.
+     */
+    @Override
+    public boolean isConfirmed()
+    {
+        String value = getConfirmed();
+        return (value != null && value.equals(User.CONFIRM_DATA));
+    }
+
+    /**
+     * Updates the last login date in the database.
+     *
+     * @throws Exception A generic exception.
+     */
+    @Override
+    public void updateLastLogin()
+        throws Exception
+    {
+        setLastLogin(new java.util.Date());
+    }
+
+    /* (non-Javadoc)
+        * @see org.apache.turbine.om.security.UserDelegate#getUserDelegate()
+        */
+    @Override
+       public TurbineUser getUserDelegate()
+    {
+        return userDelegate;
+    }
+
+    /* (non-Javadoc)
+        * @see 
org.apache.turbine.om.security.UserDelegate#setUserDelegate(org.apache.fulcrum.security.model.turbine.entity.TurbineUser)
+        */
+    @Override
+       public void setUserDelegate(TurbineUser userDelegate)
+    {
+        this.userDelegate = userDelegate;
+    }
+}

Modified: 
turbine/core/trunk/src/java/org/apache/turbine/om/security/TurbineUserDelegate.java
URL: 
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/om/security/TurbineUserDelegate.java?rev=1812628&r1=1812627&r2=1812628&view=diff
==============================================================================
--- 
turbine/core/trunk/src/java/org/apache/turbine/om/security/TurbineUserDelegate.java
 (original)
+++ 
turbine/core/trunk/src/java/org/apache/turbine/om/security/TurbineUserDelegate.java
 Thu Oct 19 12:34:25 2017
@@ -21,8 +21,8 @@ package org.apache.turbine.om.security;
 import org.apache.fulcrum.security.model.turbine.entity.TurbineUser;
 
 /**
- * Marker interface 
- * 
+ * Marker interface
+ *
  * @author gkallidis
  *
  */
@@ -42,4 +42,4 @@ public interface TurbineUserDelegate {
         */
        public abstract void setUserDelegate(TurbineUser userDelegate);
 
-}
\ No newline at end of file
+}

Modified: turbine/core/trunk/src/java/org/apache/turbine/pipeline/XmlValve.java
URL: 
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/pipeline/XmlValve.java?rev=1812628&r1=1812627&r2=1812628&view=diff
==============================================================================
--- turbine/core/trunk/src/java/org/apache/turbine/pipeline/XmlValve.java 
(original)
+++ turbine/core/trunk/src/java/org/apache/turbine/pipeline/XmlValve.java Thu 
Oct 19 12:34:25 2017
@@ -55,4 +55,4 @@ public class XmlValve
     {
         this.clazz = clazz;
     }
-}
\ No newline at end of file
+}

Modified: 
turbine/core/trunk/src/java/org/apache/turbine/services/jsonrpc/JSONProcessor.java
URL: 
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/services/jsonrpc/JSONProcessor.java?rev=1812628&r1=1812627&r2=1812628&view=diff
==============================================================================
--- 
turbine/core/trunk/src/java/org/apache/turbine/services/jsonrpc/JSONProcessor.java
 (original)
+++ 
turbine/core/trunk/src/java/org/apache/turbine/services/jsonrpc/JSONProcessor.java
 Thu Oct 19 12:34:25 2017
@@ -1,5 +1,24 @@
 package org.apache.turbine.services.jsonrpc;
 
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 import java.io.CharArrayWriter;
 
 import javax.servlet.http.HttpServletRequest;

Modified: 
turbine/core/trunk/src/java/org/apache/turbine/services/pull/tools/UITool.java
URL: 
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/services/pull/tools/UITool.java?rev=1812628&r1=1812627&r2=1812628&view=diff
==============================================================================
--- 
turbine/core/trunk/src/java/org/apache/turbine/services/pull/tools/UITool.java 
(original)
+++ 
turbine/core/trunk/src/java/org/apache/turbine/services/pull/tools/UITool.java 
Thu Oct 19 12:34:25 2017
@@ -1,389 +1,389 @@
-package org.apache.turbine.services.pull.tools;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.turbine.annotation.TurbineService;
-import org.apache.turbine.om.security.User;
-import org.apache.turbine.pipeline.PipelineData;
-import org.apache.turbine.services.pull.ApplicationTool;
-import org.apache.turbine.services.ui.UIService;
-import org.apache.turbine.util.RunData;
-import org.apache.turbine.util.ServerData;
-
-/**
- * Manages all UI elements for a Turbine Application. Any UI element can be
- * accessed in any template using the $ui handle (assuming you use the default
- * PullService configuration). So, for example, you could access the background
- * color for your pages by using $ui.bgcolor
- * <p>
- * This implementation provides a single level of inheritance in that if a
- * property does not exist in a non-default skin, the value from the default
- * skin will be used. By only requiring values different to those stored in
- * the default skin to appear in the non-default skins the amount of memory
- * consumed in cases where the UserManager instance is used at a non-global
- * scope will potentially be reduced due to the fact that a shared instance of
- * the default skin properties can be used. Note that this inheritance only
- * applies to property values - it does not apply to any images or stylesheets
- * that may form part of your skins.
- * <p>
- * This is an application pull tool for the template system. You should not
- * use it in a normal application!  Within Java code you should use TurbineUI.
- * <p>
- *
- * This is an application pull tool for the template system. You should
- * <strong>only</strong> use it in a normal application to set the skin
- * attribute for a user (setSkin(User user, String skin)) and to initialize it
- * for the user, otherwise use TurbineUI is probably the way to go.
- *
- * @author <a href="mailto:[email protected]";>Jason van Zyl</a>
- * @author <a href="mailto:[email protected]";>James Coltman</a>
- * @author <a href="mailto:[email protected]";>Henning P. Schmiedehausen</a>
- * @author <a href="mailto:[email protected]";>Scott Eade</a>
- * @version $Id$
- * @see UIService
- */
-public class UITool implements ApplicationTool
-{
-    /** Logging */
-    private static Log log = LogFactory.getLog(UITool.class);
-
-    /**
-     * Attribute name of skinName value in User's temp hashmap.
-     */
-    public static final String SKIN_ATTRIBUTE = UITool.class.getName()+ 
".skin";
-
-    /**
-     * The actual skin being used for the webapp.
-     */
-    private String skinName;
-
-    /**
-     * The UI service.
-     */
-    @TurbineService
-    private UIService uiService;
-
-    /**
-     * Refresh the tool.
-     */
-    @Override
-    public void refresh()
-    {
-        uiService.refresh(getSkin());
-        log.debug("UITool refreshed for skin: " + getSkin());
-    }
-
-    /**
-     * Provide access to the list of available skin names.
-     *
-     * @return the available skin names.
-     */
-    public String[] getSkinNames()
-    {
-        return uiService.getSkinNames();
-    }
-
-    /**
-     * Get the name of the default skin name for the web application from the
-     * TurbineResources.properties file. If the property is not present the
-     * name of the default skin will be returned.  Note that the web 
application
-     * skin name may be something other than default, in which case its
-     * properties will default to the skin with the name "default".
-     *
-     * @return the name of the default skin for the web application.
-     */
-    public String getWebappSkinName()
-    {
-        return uiService.getWebappSkinName();
-    }
-
-    /**
-     * Retrieve a skin property.  If the property is not defined in the current
-     * skin the value for the default skin will be provided.  If the current
-     * skin does not exist then the skin configured for the webapp will be 
used.
-     * If the webapp skin does not exist the default skin will be used.  If the
-     * default skin does not exist then <code>null</code> will be returned.
-     *
-     * @param key the key to retrieve from the skin.
-     * @return the value of the property for the named skin (defaulting to the
-     * default skin), the webapp skin, the default skin or <code>null</code>,
-     * depending on whether or not the property or skins exist.
-     */
-    public String get(String key)
-    {
-        return uiService.get(getSkin(), key);
-    }
-
-    /**
-     * Retrieve the skin name.
-     * @return the selected skin name
-     */
-    public String getSkin()
-    {
-        return skinName;
-    }
-
-    /**
-     * Set the skin name to the skin from the TurbineResources.properties file.
-     * If the property is not present use the "default" skin.
-     */
-    public void setSkin()
-    {
-        skinName = uiService.getWebappSkinName();
-    }
-
-    /**
-     * Set the skin name to the specified skin.
-     *
-     * @param skinName the skin name to use.
-     */
-    public void setSkin(String skinName)
-    {
-        this.skinName = skinName;
-    }
-
-    /**
-     * Set the skin name when the tool is configured to be loaded on a
-     * per-request basis. By default it calls getSkin to return the skin
-     * specified in TurbineResources.properties. Developers can write a 
subclass
-     * of UITool that overrides this method to determine the skin to use based
-     * on information held in the request.
-     *
-     * @param data a RunData instance
-     */
-    protected void setSkin(RunData data)
-    {
-        setSkin();
-    }
-
-    /**
-     * Set the skin name when the tool is configured to be loaded on a
-     * per-session basis. If the user's temp hashmap contains a value in the
-     * attribute specified by the String constant SKIN_ATTRIBUTE then that is
-     * returned. Otherwise it calls getSkin to return the skin specified in
-     * TurbineResources.properties.
-     *
-     * @param user a User instance
-     */
-    protected void setSkin(User user)
-    {
-        if (user.getTemp(SKIN_ATTRIBUTE) == null)
-        {
-            setSkin();
-        }
-        else
-        {
-            setSkin((String) user.getTemp(SKIN_ATTRIBUTE));
-        }
-    }
-
-    /**
-     * Set the skin name in the user's temp hashmap for the current session.
-     *
-     * @param user a User instance
-     * @param skin the skin name for the session
-     */
-    public static void setSkin(User user, String skin)
-    {
-        user.setTemp(SKIN_ATTRIBUTE, skin);
-    }
-
-    /**
-     * Retrieve the URL for an image that is part of the skin. The images are
-     * stored in the WEBAPP/resources/ui/skins/[SKIN]/images directory.
-     *
-     * <p>Use this if for some reason your server name, server scheme, or 
server
-     * port change on a per request basis. I'm not sure if this would happen in
-     * a load balanced situation. I think in most cases the image(String image)
-     * method would probably be enough, but I'm not absolutely positive.
-     *
-     * @param imageId the id of the image whose URL will be generated.
-     * @param data the RunData to use as the source of the ServerData to use as
-     * the basis for the URL.
-     * @return the image URL
-     */
-    public String image(String imageId, RunData data)
-    {
-        return image(imageId, data.getServerData());
-    }
-
-    /**
-     * Retrieve the URL for an image that is part of the skin. The images are
-     * stored in the WEBAPP/resources/ui/skins/[SKIN]/images directory.
-     *
-     * <p>Use this if for some reason your server name, server scheme, or 
server
-     * port change on a per request basis. I'm not sure if this would happen in
-     * a load balanced situation. I think in most cases the image(String image)
-     * method would probably be enough, but I'm not absolutely positive.
-     *
-     * @param imageId the id of the image whose URL will be generated.
-     * @param serverData the serverData to use as the basis for the URL.
-     * @return the image URL
-     */
-    public String image(String imageId, ServerData serverData)
-    {
-        return uiService.image(getSkin(), imageId, serverData);
-    }
-
-    /**
-     * Retrieve the URL for an image that is part of the skin. The images are
-     * stored in the WEBAPP/resources/ui/skins/[SKIN]/images directory.
-     *
-     * @param imageId the id of the image whose URL will be generated.
-     * @return the image URL
-     */
-    public String image(String imageId)
-    {
-        return uiService.image(getSkin(), imageId);
-    }
-
-    /**
-     * Retrieve the URL for the style sheet that is part of the skin. The style
-     * is stored in the WEBAPP/resources/ui/skins/[SKIN] directory with the
-     * filename skin.css
-     *
-     * <p>Use this if for some reason your server name, server scheme, or 
server
-     * port change on a per request basis. I'm not sure if this would happen in
-     * a load balanced situation. I think in most cases the style() method 
would
-     * probably be enough, but I'm not absolutely positive.
-     *
-     * @param data the RunData to use as the source of the ServerData to use as
-     * the basis for the URL.
-     * @return the CSS URL
-     */
-    public String getStylecss(RunData data)
-    {
-        return getStylecss(data.getServerData());
-    }
-
-    /**
-     * Retrieve the URL for the style sheet that is part of the skin. The style
-     * is stored in the WEBAPP/resources/ui/skins/[SKIN] directory with the
-     * filename skin.css
-     *
-     * <p>Use this if for some reason your server name, server scheme, or 
server
-     * port change on a per request basis. I'm not sure if this would happen in
-     * a load balanced situation. I think in most cases the style() method 
would
-     * probably be enough, but I'm not absolutely positive.
-     *
-     * @param serverData the serverData to use as the basis for the URL.
-     * @return the CSS URL
-     */
-    public String getStylecss(ServerData serverData)
-    {
-        return uiService.getStylecss(getSkin(), serverData);
-    }
-
-    /**
-     * Retrieve the URL for the style sheet that is part of the skin. The style
-     * is stored in the WEBAPP/resources/ui/skins/[SKIN] directory with the
-     * filename skin.css
-     * @return the CSS URL
-     */
-    public String getStylecss()
-    {
-        return uiService.getStylecss(getSkin());
-    }
-
-    /**
-     * Retrieve the URL for a given script that is part of the skin. The script
-     * is stored in the WEBAPP/resources/ui/skins/[SKIN] directory.
-     *
-     * <p>Use this if for some reason your server name, server scheme, or 
server
-     * port change on a per request basis. I'm not sure if this would happen in
-     * a load balanced situation. I think in most cases the image(String image)
-     * method would probably be enough, but I'm not absolutely positive.
-     *
-     * @param filename the name of the script file whose URL will be generated.
-     * @param data the RunDate to use as the source of the ServerData to use as
-     * the basis for the URL.
-     * @return the script URL
-     */
-    public String getScript(String filename, RunData data)
-    {
-        return getScript(filename, data.getServerData());
-    }
-
-    /**
-     * Retrieve the URL for a given script that is part of the skin. The script
-     * is stored in the WEBAPP/resources/ui/skins/[SKIN] directory.
-     *
-     * <p>Use this if for some reason your server name, server scheme, or 
server
-     * port change on a per request basis. I'm not sure if this would happen in
-     * a load balanced situation. I think in most cases the image(String image)
-     * method would probably be enough, but I'm not absolutely positive.
-     *
-     * @param filename the name of the script file whose URL will be generated.
-     * @param serverData the serverData to use as the basis for the URL.
-     * @return the script URL
-     */
-    public String getScript(String filename, ServerData serverData)
-    {
-        return uiService.getScript(getSkin(), filename, serverData);
-    }
-
-    /**
-     * Retrieve the URL for a given script that is part of the skin. The script
-     * is stored in the WEBAPP/resources/ui/skins/[SKIN] directory.
-     *
-     * @param filename the name of the script file whose URL will be generated.
-     * @return the script URL
-     */
-    public String getScript(String filename)
-    {
-        return uiService.getScript(getSkin(), filename);
-    }
-
-    /**
-     * Initialize the UITool object.
-     *
-     * @param data This is null, RunData or User depending upon specified tool
-     * scope.
-     */
-    @Override
-    public void init(Object data)
-    {
-        if (data == null)
-        {
-            log.debug("UITool scope is global");
-            setSkin();
-        }
-        else if (data instanceof RunData)
-        {
-            log.debug("UITool scope is request");
-            setSkin((RunData) data);
-        }
-        else if (data instanceof PipelineData)
-        {
-            PipelineData pipelineData = (PipelineData) data;
-            RunData runData = (RunData)pipelineData;
-            log.debug("UITool scope is request");
-            setSkin(runData);
-        }
-        else if (data instanceof User)
-        {
-            log.debug("UITool scope is session");
-            setSkin((User) data);
-        }
-    }
-
-}
+package org.apache.turbine.services.pull.tools;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.turbine.annotation.TurbineService;
+import org.apache.turbine.om.security.User;
+import org.apache.turbine.pipeline.PipelineData;
+import org.apache.turbine.services.pull.ApplicationTool;
+import org.apache.turbine.services.ui.UIService;
+import org.apache.turbine.util.RunData;
+import org.apache.turbine.util.ServerData;
+
+/**
+ * Manages all UI elements for a Turbine Application. Any UI element can be
+ * accessed in any template using the $ui handle (assuming you use the default
+ * PullService configuration). So, for example, you could access the background
+ * color for your pages by using $ui.bgcolor
+ * <p>
+ * This implementation provides a single level of inheritance in that if a
+ * property does not exist in a non-default skin, the value from the default
+ * skin will be used. By only requiring values different to those stored in
+ * the default skin to appear in the non-default skins the amount of memory
+ * consumed in cases where the UserManager instance is used at a non-global
+ * scope will potentially be reduced due to the fact that a shared instance of
+ * the default skin properties can be used. Note that this inheritance only
+ * applies to property values - it does not apply to any images or stylesheets
+ * that may form part of your skins.
+ * <p>
+ * This is an application pull tool for the template system. You should not
+ * use it in a normal application!  Within Java code you should use TurbineUI.
+ * <p>
+ *
+ * This is an application pull tool for the template system. You should
+ * <strong>only</strong> use it in a normal application to set the skin
+ * attribute for a user (setSkin(User user, String skin)) and to initialize it
+ * for the user, otherwise use TurbineUI is probably the way to go.
+ *
+ * @author <a href="mailto:[email protected]";>Jason van Zyl</a>
+ * @author <a href="mailto:[email protected]";>James Coltman</a>
+ * @author <a href="mailto:[email protected]";>Henning P. Schmiedehausen</a>
+ * @author <a href="mailto:[email protected]";>Scott Eade</a>
+ * @version $Id$
+ * @see UIService
+ */
+public class UITool implements ApplicationTool
+{
+    /** Logging */
+    private static Log log = LogFactory.getLog(UITool.class);
+
+    /**
+     * Attribute name of skinName value in User's temp hashmap.
+     */
+    public static final String SKIN_ATTRIBUTE = UITool.class.getName()+ 
".skin";
+
+    /**
+     * The actual skin being used for the webapp.
+     */
+    private String skinName;
+
+    /**
+     * The UI service.
+     */
+    @TurbineService
+    private UIService uiService;
+
+    /**
+     * Refresh the tool.
+     */
+    @Override
+    public void refresh()
+    {
+        uiService.refresh(getSkin());
+        log.debug("UITool refreshed for skin: " + getSkin());
+    }
+
+    /**
+     * Provide access to the list of available skin names.
+     *
+     * @return the available skin names.
+     */
+    public String[] getSkinNames()
+    {
+        return uiService.getSkinNames();
+    }
+
+    /**
+     * Get the name of the default skin name for the web application from the
+     * TurbineResources.properties file. If the property is not present the
+     * name of the default skin will be returned.  Note that the web 
application
+     * skin name may be something other than default, in which case its
+     * properties will default to the skin with the name "default".
+     *
+     * @return the name of the default skin for the web application.
+     */
+    public String getWebappSkinName()
+    {
+        return uiService.getWebappSkinName();
+    }
+
+    /**
+     * Retrieve a skin property.  If the property is not defined in the current
+     * skin the value for the default skin will be provided.  If the current
+     * skin does not exist then the skin configured for the webapp will be 
used.
+     * If the webapp skin does not exist the default skin will be used.  If the
+     * default skin does not exist then <code>null</code> will be returned.
+     *
+     * @param key the key to retrieve from the skin.
+     * @return the value of the property for the named skin (defaulting to the
+     * default skin), the webapp skin, the default skin or <code>null</code>,
+     * depending on whether or not the property or skins exist.
+     */
+    public String get(String key)
+    {
+        return uiService.get(getSkin(), key);
+    }
+
+    /**
+     * Retrieve the skin name.
+     * @return the selected skin name
+     */
+    public String getSkin()
+    {
+        return skinName;
+    }
+
+    /**
+     * Set the skin name to the skin from the TurbineResources.properties file.
+     * If the property is not present use the "default" skin.
+     */
+    public void setSkin()
+    {
+        skinName = uiService.getWebappSkinName();
+    }
+
+    /**
+     * Set the skin name to the specified skin.
+     *
+     * @param skinName the skin name to use.
+     */
+    public void setSkin(String skinName)
+    {
+        this.skinName = skinName;
+    }
+
+    /**
+     * Set the skin name when the tool is configured to be loaded on a
+     * per-request basis. By default it calls getSkin to return the skin
+     * specified in TurbineResources.properties. Developers can write a 
subclass
+     * of UITool that overrides this method to determine the skin to use based
+     * on information held in the request.
+     *
+     * @param data a RunData instance
+     */
+    protected void setSkin(RunData data)
+    {
+        setSkin();
+    }
+
+    /**
+     * Set the skin name when the tool is configured to be loaded on a
+     * per-session basis. If the user's temp hashmap contains a value in the
+     * attribute specified by the String constant SKIN_ATTRIBUTE then that is
+     * returned. Otherwise it calls getSkin to return the skin specified in
+     * TurbineResources.properties.
+     *
+     * @param user a User instance
+     */
+    protected void setSkin(User user)
+    {
+        if (user.getTemp(SKIN_ATTRIBUTE) == null)
+        {
+            setSkin();
+        }
+        else
+        {
+            setSkin((String) user.getTemp(SKIN_ATTRIBUTE));
+        }
+    }
+
+    /**
+     * Set the skin name in the user's temp hashmap for the current session.
+     *
+     * @param user a User instance
+     * @param skin the skin name for the session
+     */
+    public static void setSkin(User user, String skin)
+    {
+        user.setTemp(SKIN_ATTRIBUTE, skin);
+    }
+
+    /**
+     * Retrieve the URL for an image that is part of the skin. The images are
+     * stored in the WEBAPP/resources/ui/skins/[SKIN]/images directory.
+     *
+     * <p>Use this if for some reason your server name, server scheme, or 
server
+     * port change on a per request basis. I'm not sure if this would happen in
+     * a load balanced situation. I think in most cases the image(String image)
+     * method would probably be enough, but I'm not absolutely positive.
+     *
+     * @param imageId the id of the image whose URL will be generated.
+     * @param data the RunData to use as the source of the ServerData to use as
+     * the basis for the URL.
+     * @return the image URL
+     */
+    public String image(String imageId, RunData data)
+    {
+        return image(imageId, data.getServerData());
+    }
+
+    /**
+     * Retrieve the URL for an image that is part of the skin. The images are
+     * stored in the WEBAPP/resources/ui/skins/[SKIN]/images directory.
+     *
+     * <p>Use this if for some reason your server name, server scheme, or 
server
+     * port change on a per request basis. I'm not sure if this would happen in
+     * a load balanced situation. I think in most cases the image(String image)
+     * method would probably be enough, but I'm not absolutely positive.
+     *
+     * @param imageId the id of the image whose URL will be generated.
+     * @param serverData the serverData to use as the basis for the URL.
+     * @return the image URL
+     */
+    public String image(String imageId, ServerData serverData)
+    {
+        return uiService.image(getSkin(), imageId, serverData);
+    }
+
+    /**
+     * Retrieve the URL for an image that is part of the skin. The images are
+     * stored in the WEBAPP/resources/ui/skins/[SKIN]/images directory.
+     *
+     * @param imageId the id of the image whose URL will be generated.
+     * @return the image URL
+     */
+    public String image(String imageId)
+    {
+        return uiService.image(getSkin(), imageId);
+    }
+
+    /**
+     * Retrieve the URL for the style sheet that is part of the skin. The style
+     * is stored in the WEBAPP/resources/ui/skins/[SKIN] directory with the
+     * filename skin.css
+     *
+     * <p>Use this if for some reason your server name, server scheme, or 
server
+     * port change on a per request basis. I'm not sure if this would happen in
+     * a load balanced situation. I think in most cases the style() method 
would
+     * probably be enough, but I'm not absolutely positive.
+     *
+     * @param data the RunData to use as the source of the ServerData to use as
+     * the basis for the URL.
+     * @return the CSS URL
+     */
+    public String getStylecss(RunData data)
+    {
+        return getStylecss(data.getServerData());
+    }
+
+    /**
+     * Retrieve the URL for the style sheet that is part of the skin. The style
+     * is stored in the WEBAPP/resources/ui/skins/[SKIN] directory with the
+     * filename skin.css
+     *
+     * <p>Use this if for some reason your server name, server scheme, or 
server
+     * port change on a per request basis. I'm not sure if this would happen in
+     * a load balanced situation. I think in most cases the style() method 
would
+     * probably be enough, but I'm not absolutely positive.
+     *
+     * @param serverData the serverData to use as the basis for the URL.
+     * @return the CSS URL
+     */
+    public String getStylecss(ServerData serverData)
+    {
+        return uiService.getStylecss(getSkin(), serverData);
+    }
+
+    /**
+     * Retrieve the URL for the style sheet that is part of the skin. The style
+     * is stored in the WEBAPP/resources/ui/skins/[SKIN] directory with the
+     * filename skin.css
+     * @return the CSS URL
+     */
+    public String getStylecss()
+    {
+        return uiService.getStylecss(getSkin());
+    }
+
+    /**
+     * Retrieve the URL for a given script that is part of the skin. The script
+     * is stored in the WEBAPP/resources/ui/skins/[SKIN] directory.
+     *
+     * <p>Use this if for some reason your server name, server scheme, or 
server
+     * port change on a per request basis. I'm not sure if this would happen in
+     * a load balanced situation. I think in most cases the image(String image)
+     * method would probably be enough, but I'm not absolutely positive.
+     *
+     * @param filename the name of the script file whose URL will be generated.
+     * @param data the RunDate to use as the source of the ServerData to use as
+     * the basis for the URL.
+     * @return the script URL
+     */
+    public String getScript(String filename, RunData data)
+    {
+        return getScript(filename, data.getServerData());
+    }
+
+    /**
+     * Retrieve the URL for a given script that is part of the skin. The script
+     * is stored in the WEBAPP/resources/ui/skins/[SKIN] directory.
+     *
+     * <p>Use this if for some reason your server name, server scheme, or 
server
+     * port change on a per request basis. I'm not sure if this would happen in
+     * a load balanced situation. I think in most cases the image(String image)
+     * method would probably be enough, but I'm not absolutely positive.
+     *
+     * @param filename the name of the script file whose URL will be generated.
+     * @param serverData the serverData to use as the basis for the URL.
+     * @return the script URL
+     */
+    public String getScript(String filename, ServerData serverData)
+    {
+        return uiService.getScript(getSkin(), filename, serverData);
+    }
+
+    /**
+     * Retrieve the URL for a given script that is part of the skin. The script
+     * is stored in the WEBAPP/resources/ui/skins/[SKIN] directory.
+     *
+     * @param filename the name of the script file whose URL will be generated.
+     * @return the script URL
+     */
+    public String getScript(String filename)
+    {
+        return uiService.getScript(getSkin(), filename);
+    }
+
+    /**
+     * Initialize the UITool object.
+     *
+     * @param data This is null, RunData or User depending upon specified tool
+     * scope.
+     */
+    @Override
+    public void init(Object data)
+    {
+        if (data == null)
+        {
+            log.debug("UITool scope is global");
+            setSkin();
+        }
+        else if (data instanceof RunData)
+        {
+            log.debug("UITool scope is request");
+            setSkin((RunData) data);
+        }
+        else if (data instanceof PipelineData)
+        {
+            PipelineData pipelineData = (PipelineData) data;
+            RunData runData = (RunData)pipelineData;
+            log.debug("UITool scope is request");
+            setSkin(runData);
+        }
+        else if (data instanceof User)
+        {
+            log.debug("UITool scope is session");
+            setSkin((User) data);
+        }
+    }
+
+}


Reply via email to