Index: lams_central/build.xml =================================================================== RCS file: /usr/local/cvsroot/lams_central/build.xml,v diff -u -r1.18 -r1.19 --- lams_central/build.xml 30 Sep 2005 01:36:42 -0000 1.18 +++ lams_central/build.xml 13 Oct 2005 03:12:00 -0000 1.19 @@ -137,6 +137,7 @@ webxml="${webinf}/web.xml"> + @@ -215,6 +216,7 @@ + + + Index: lams_central/conf/xdoclet/taglibs.xml =================================================================== RCS file: /usr/local/cvsroot/lams_central/conf/xdoclet/taglibs.xml,v diff -u -r1.2 -r1.3 --- lams_central/conf/xdoclet/taglibs.xml 19 Sep 2005 01:02:18 -0000 1.2 +++ lams_central/conf/xdoclet/taglibs.xml 13 Oct 2005 03:11:38 -0000 1.3 @@ -75,3 +75,8 @@ fck-editor /WEB-INF/fckeditor/tlds/FCKeditor.tld + + + tags-lams + /WEB-INF/lams.tld + Index: lams_central/src/java/org/lamsfoundation/lams/web/tag/UserTag.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/web/tag/UserTag.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_central/src/java/org/lamsfoundation/lams/web/tag/UserTag.java 13 Oct 2005 03:11:38 -0000 1.1 @@ -0,0 +1,127 @@ +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ***********************************************************************/ + +package org.lamsfoundation.lams.web.tag; + +import java.io.IOException; + +import javax.servlet.http.HttpSession; +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.JspWriter; +import javax.servlet.jsp.tagext.TagSupport; + +import org.apache.log4j.Logger; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.apache.commons.beanutils.PropertyUtils; + +/** + * Output a property from the userDTO object in the shared session. + * + * Has a single paramter "property", which is the name of the property from the UserDTO to be accessed. + * May be: userID, firstName, lastName, login, email. + * + * Doesn't support theme yet - to be added when we work out what we want from the theme details. + * + * @jsp.tag name="user" + * bodycontent="empty" + * display-name="user details" + * description="Output details from the shared session UserDTO object" + * + * @author Fiona Malikoff + */ +public class UserTag extends TagSupport { + + private static final Logger log = Logger.getLogger(UserTag.class); + + /** The property to be output */ + private String property = null; + /** + * + */ + public UserTag() { + super(); + } + + public int doStartTag() throws JspException { + HttpSession ss = SessionManager.getSession(); + if ( ss != null ) { + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + if ( user != null ) { + processProperty(user); + } else { + log.warn("UserTag unable to access user details as userDTO is missing. Session is "+ss); + } + } else { + log.warn("UserTag unable to access user details as shared session is missing"); + } + + return SKIP_BODY; + } + + public int doEndTag() { + return EVAL_PAGE; + } + + private void processProperty(UserDTO user) throws JspException { + try { + + if ( property != null ) { + Object value = null; + + try { + value = PropertyUtils.getProperty(user, property); + } catch (Exception e) { + log.warn("UserTag unable to write out user details due to exception while accessing property value. User id "+user.getUserID(), e); + } + + if ( value != null ) { + JspWriter writer = pageContext.getOut(); + writer.print(value); + } + + } + + } catch ( IOException e ) { + log.error("UserTag unable to write out user details due to IOException. User id "+user.getUserID(), e); + throw new JspException(e); + } + } + /** + * @jsp.attribute required="true" + * rtexprvalue="true" + * type="String" + * description="Property of UserDTO to be accessed." + * + * @return Returns the property. + */ + public String getProperty() { + return property; + } + /** + * @param property The property to set. + */ + public void setProperty(String property) { + this.property = property; + } +} Index: lams_central/web/author.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/author.jsp,v diff -u -r1.1 -r1.2 --- lams_central/web/author.jsp 19 Sep 2005 02:22:32 -0000 1.1 +++ lams_central/web/author.jsp 13 Oct 2005 03:11:38 -0000 1.2 @@ -1,3 +1,4 @@ +<%@ taglib uri="tags-lams" prefix="lams" %> @@ -218,19 +219,18 @@ - - + &serverURL=<%=pathToRoot%>"> &serverURL=<%=pathToRoot%>" quality="high" scale="noscale" bgcolor="#B3B7C8" Index: lams_central/web/WEB-INF/lams.tld =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/WEB-INF/Attic/lams.tld,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_central/web/WEB-INF/lams.tld 13 Oct 2005 03:11:38 -0000 1.1 @@ -0,0 +1,27 @@ + + + + + + 1.0 + 1.1 + lams + + + + + + user + org.lamsfoundation.lams.web.tag.UserTag + + + + property + true + true + + + + + + Index: lams_central/web/WEB-INF/web.xml =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/WEB-INF/Attic/web.xml,v diff -u -r1.8 -r1.9 --- lams_central/web/WEB-INF/web.xml 19 Sep 2005 01:02:18 -0000 1.8 +++ lams_central/web/WEB-INF/web.xml 13 Oct 2005 03:11:38 -0000 1.9 @@ -27,37 +27,49 @@ contextConfigLocation classpath:/org/lamsfoundation/lams/applicationContext.xml + classpath:/org/lamsfoundation/lams/tool/toolApplicationContext.xml classpath:/org/lamsfoundation/lams/contentrepository/applicationContext.xml classpath:/org/lamsfoundation/lams/authoring/authoringApplicationContext.xml classpath:/org/lamsfoundation/lams/workspace/workspaceApplicationContext.xml - + + SystemSessionFilter + + org.lamsfoundation.lams.web.session.SystemSessionFilter + + + + hibernateFilter + + org.lamsfoundation.lams.util.CustomizedOpenSessionInViewFilter + + + sessionFactoryBeanName + coreSessionFactory + + - + + SystemSessionFilter + /* + + + hibernateFilter + /* + org.springframework.web.context.ContextLoaderListener + + org.lamsfoundation.lams.web.SessionListener - - org.lamsfoundation.lams.web.SharedSession - - + storeLD @@ -268,6 +280,11 @@ /WEB-INF/fckeditor/tlds/FCKeditor.tld + + tags-lams + /WEB-INF/lams.tld + +