001package votorola.a.response; // Copyright 2008, Michael Allan.  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Votorola Software"), to deal in the Votorola Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Votorola Software, and to permit persons to whom the Votorola Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Votorola Software. THE VOTOROLA SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE VOTOROLA SOFTWARE OR THE USE OR OTHER DEALINGS IN THE VOTOROLA SOFTWARE.
002
003import java.util.*;
004import votorola.a.*;
005import votorola.g.*;
006import votorola.g.option.*;
007
008
009/** Responder for the command 'version' - to ask what version of software the vote-server
010  * is running.
011  *
012  *     @see <a href='../../../../../s/manual.xht#Mail-Response-version'
013  *                           >../../s/manual.xht#Mail-Response-version</a>
014  */
015public final class CR_Version extends CommandResponder.Base
016{
017
018    /** Constructs a CR_Version.
019      */
020    public CR_Version( VoterService voterService )
021    {
022        super( voterService, "a.response.CR_Version." );
023    }
024
025
026   // - C o m m a n d - R e s p o n d e r ------------------------------------------------
027
028
029    /** Returns true.
030      */
031    public @Override boolean acceptsAnonymousIssue() { return true; }
032
033
034
035    public @Override Exception respond( final String[] argv,
036      final CommandResponder.Session session )
037    {
038        final ReplyBuilder replyB = session.replyBuilder();
039        final Map<String,Option> optionMap = compileBaseOptions( session );
040        {
041            final int aFirstNonOption = parse( argv, optionMap, session ); // rearranges argv
042            if( aFirstNonOption == -1 ) return null; // parse error, message already appended
043
044            if( optionMap.get("a.voter.CommandResponder.option.help").hasOccured() )
045            {
046                help( session );
047                return null;
048            }
049        }
050
051        replyB.lappendlnn( "a.response.CR_Version.reply(1)", Votorola.VERSION );
052        return null;
053    }
054
055
056
057}