001    //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/tags/2.1/src/org/deegree/ogcwebservices/csw/discovery/SearchStatus.java $
002    /*----------------    FILE HEADER  ------------------------------------------
003    
004     This file is part of deegree.
005     Copyright (C) 2001-2006 by:
006     EXSE, Department of Geography, University of Bonn
007     http://www.giub.uni-bonn.de/deegree/
008     lat/lon GmbH
009     http://www.lat-lon.de
010    
011     This library is free software; you can redistribute it and/or
012     modify it under the terms of the GNU Lesser General Public
013     License as published by the Free Software Foundation; either
014     version 2.1 of the License, or (at your option) any later version.
015    
016     This library is distributed in the hope that it will be useful,
017     but WITHOUT ANY WARRANTY; without even the implied warranty of
018     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
019     Lesser General Public License for more details.
020    
021     You should have received a copy of the GNU Lesser General Public
022     License along with this library; if not, write to the Free Software
023     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
024    
025     Contact:
026    
027     Andreas Poth
028     lat/lon GmbH
029     Aennchenstr. 19
030     53115 Bonn
031     Germany
032     E-Mail: poth@lat-lon.de
033    
034     Prof. Dr. Klaus Greve
035     Department of Geography
036     University of Bonn
037     Meckenheimer Allee 166
038     53115 Bonn
039     Germany
040     E-Mail: greve@giub.uni-bonn.de
041    
042    
043     ---------------------------------------------------------------------------*/
044    package org.deegree.ogcwebservices.csw.discovery;
045    
046    import java.util.Date;
047    
048    import org.deegree.framework.util.TimeTools;
049    import org.deegree.ogcwebservices.InvalidParameterValueException;
050    
051    /**
052     * Class representation of a <csw:SearchStatus>-element.
053     * 
054     * @author <a href="mailto:poth@lat-lon.de">Andreas Poth </a>
055     * @author <a href="mailto:tfr@users.sourceforge.net">Torsten Friebe </a>
056     * @author <a href="mailto:tfr@users.sourceforge.net">Markus Schneider </a>
057     * 
058     * @author last edited by: $Author: apoth $
059     * 
060     * @version 2.0, $Revision: 6705 $, $Date: 2007-04-26 21:55:39 +0200 (Do, 26 Apr 2007) $
061     */
062    public class SearchStatus {
063    
064        private static final String[] STATES = { "complete", "subset", "interim", "processing", "none" };
065    
066        private String status;
067    
068        private Date timestamp;
069    
070        /**
071         * 
072         * 
073         */
074        private SearchStatus() {
075            this.timestamp = new Date( System.currentTimeMillis() );
076        }
077    
078        /**
079         * 
080         * @param status
081         */
082        SearchStatus( String status ) {
083            this();
084            for ( int i = 0; i < STATES.length; i++ ) {
085                String aState = STATES[i];
086                if ( aState.equalsIgnoreCase( status ) ) {
087                    this.status = status;
088                }
089            }
090        }
091    
092        /**
093         * 
094         * @param status
095         * @param timestamp
096         */
097        SearchStatus( String status, Date timestamp ) {
098            this( status );
099            this.timestamp = timestamp;
100        }
101    
102        /**
103         * Create a new instance from status-String and timestamp-String.
104         * 
105         * TODO: parse timestampString
106         * 
107         * @param status
108         * @param timestampString
109         * @throws InvalidParameterValueException
110         */
111        SearchStatus( String status, String timestampString ) {
112            this( status );
113            this.timestamp = TimeTools.createCalendar( timestampString ).getTime();
114        }
115    
116        /**
117         * possible values are:
118         * <ul>
119         * <li>complete: The request was successfully completed and valid results are available or have
120         * been returned.
121         * <li>subset: The request was successfully completed and partial valid results are available
122         * or have been returned. In this case subsequest queries with new start positions may be used
123         * to see more results.
124         * <li>interim: The request was successfully completed and partial results are available or
125         * have been returned but the results may not be valid. For example, an intermediate server in a
126         * distributed search may have failed cause the partial, invalid result set to be generated.
127         * <li>processing: The request is still processing. When completed, the response will be sent
128         * to the specified response handler.
129         * <li>none: No records found.
130         * </ul>
131         * 
132         * @return request processing status
133         */
134        public String getStatus() {
135            return this.status;
136        }
137    
138        /**
139         * @return datestamp of processing
140         */
141        public Date getTimestamp() {
142            return this.timestamp;
143        }
144    
145    }