001    //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/tags/2.1/src/org/deegree/ogcwebservices/wass/was/operation/DescribeUserResponse.java $
002    /*----------------    FILE HEADER  ------------------------------------------
003     This file is part of deegree.
004     Copyright (C) 2001-2006 by:
005     Department of Geography, University of Bonn
006     http://www.giub.uni-bonn.de/deegree/
007     lat/lon GmbH
008     http://www.lat-lon.de
009     This library is free software; you can redistribute it and/or
010     modify it under the terms of the GNU Lesser General Public
011     License as published by the Free Software Foundation; either
012     version 2.1 of the License, or (at your option) any later version.
013     This library is distributed in the hope that it will be useful,
014     but WITHOUT ANY WARRANTY; without even the implied warranty of
015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016     Lesser General Public License for more details.
017     You should have received a copy of the GNU Lesser General Public
018     License along with this library; if not, write to the Free Software
019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020     Contact:
021     Andreas Poth
022     lat/lon GmbH
023     Aennchenstraße 19
024     53177 Bonn
025     Germany
026     E-Mail: poth@lat-lon.de
027     Jens Fitzke
028     lat/lon GmbH
029     Aennchenstraße 19
030     53177 Bonn
031     Germany
032     E-Mail: jens.fitzke@uni-bonn.de
033     ---------------------------------------------------------------------------*/
034    package org.deegree.ogcwebservices.wass.was.operation;
035    
036    import java.io.IOException;
037    
038    import org.deegree.framework.xml.NamespaceContext;
039    import org.deegree.framework.xml.XMLFragment;
040    import org.deegree.framework.xml.XMLParsingException;
041    import org.deegree.framework.xml.XMLTools;
042    import org.deegree.ogcbase.CommonNamespaces;
043    import org.deegree.security.drm.model.User;
044    import org.w3c.dom.Element;
045    import org.xml.sax.SAXException;
046    
047    /**
048     * <code>DescribeUserResponse</code> is an XML document class used as response object
049     * for the DescribeUser operation.
050     * 
051     * @author <a href="mailto:schmitz@lat-lon.de">Andreas Schmitz</a>
052     * @author last edited by: $Author: bezema $
053     * 
054     * @version 2.0, $Revision: 6259 $, $Date: 2007-03-20 10:15:15 +0100 (Di, 20 Mär 2007) $
055     * 
056     * @since 2.0
057     */
058    
059    public class DescribeUserResponse extends XMLFragment {
060    
061        private static final long serialVersionUID = -4883638653028678703L;
062    
063        protected static final String XML_TEMPLATE = "describeusertemplate.xml";
064        
065        /**
066         * Constructs a new response document.
067         * 
068         * @param user the user object to extract the response values from.
069         * @param sessionID the user's session ID
070         * @throws IOException 
071         * @throws SAXException 
072         * @throws XMLParsingException 
073         */
074        public DescribeUserResponse( User user, String sessionID ) throws IOException, SAXException,
075                                                      XMLParsingException {
076            super( DescribeUserResponse.class.getResource( XML_TEMPLATE ) );
077            
078            NamespaceContext nsContext = CommonNamespaces.getNamespaceContext();
079            Element root = getRootElement();
080            root.setAttribute( "id", sessionID );
081    
082            Element userName = (Element) XMLTools.getRequiredNode( root, "UserName", nsContext );
083            Element firstName = (Element) XMLTools.getRequiredNode( root, "FirstName", nsContext );
084            Element lastName = (Element) XMLTools.getRequiredNode( root, "LastName", nsContext );
085            Element password = (Element) XMLTools.getRequiredNode( root, "Password", nsContext );
086            Element email = (Element) XMLTools.getRequiredNode( root, "EMailAddress", nsContext );
087            
088            userName.setTextContent( user.getName() );
089            firstName.setTextContent( user.getFirstName() );
090            lastName.setTextContent( user.getLastName() );
091            password.setTextContent( user.getPassword() );
092            email.setTextContent( user.getEmailAddress() );
093        }
094    
095    }
096    
097    
098    /* ********************************************************************
099    Changes to this class. What the people have been up to:
100    $Log$
101    Revision 1.5  2006/10/11 11:23:42  poth
102    first name and last name added to user description instead of name
103    
104    Revision 1.4  2006/09/18 10:57:13  poth
105    bug fix - creating userName from DescribeUser response
106    
107    Revision 1.3  2006/09/12 14:51:15  poth
108    bug fix - response XML for DescribeUser
109    
110    Revision 1.2  2006/08/24 06:42:17  poth
111    File header corrected
112    
113    Revision 1.1  2006/08/11 08:58:50  schmitz
114    WAS implements the DescribeUser operation.
115    
116    
117    
118    ********************************************************************** */