Coverage details for ui.command.IO.ImportUserFromVCardCommand

LineHitsSource
1 /*******************************************************************************
2  * InternetCafe is a software solution that helps the management of Cybercafes
3  * according with the ITALIAN DECREE LAW ON ANTI-TERROR MEASURES, 27 JULY 2005.
4  * Copyright (C) 2006 Guido Angelo Ingenito
5  
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *******************************************************************************/
20  
21 package ui.command.IO;
22  
23 import java.io.File;
240import java.io.FileReader;
25 import java.io.Reader;
260 
27 import org.apache.log4j.Logger;
28  
29 import ui.Messages;
300import ui.command.Command;
31 import base.InternetCafe;
320import base.InternetCafeManager;
33 import base.user.User;
34 import base.user.UserFactory;
35 import base.user.jcard.JCard;
360 
370public class ImportUserFromVCardCommand extends Command {
380    
390    private static final transient Logger logger = Logger.getLogger(ImportUserFromVCardCommand.class
400            .getName());
410    private File vCardFile = null;
420 
430    public ImportUserFromVCardCommand() {
440        
450    }
460    
470    /*
480     * (non-Javadoc)
490     *
500     * @see ui.command.Command#prologo()
510     */
52     @Override
530    protected void prologo() {
540        InternetCafe.setStatusBarMessage(Messages.getString("command.importuserfromvcardcommand.importinguserfromvcard")); //$NON-NLS-1$
550        javax.swing.JFileChooser chooser = new javax.swing.JFileChooser();
560        chooser.setDialogTitle(Messages.getString("command.importuserfromvcardcommand.dialog.title")); //$NON-NLS-1$
570        chooser.setFileSelectionMode(javax.swing.JFileChooser.FILES_ONLY);
580        chooser.setApproveButtonText(Messages.getString("button.select")); //$NON-NLS-1$
590        if (chooser.showOpenDialog(null) == javax.swing.JFileChooser.APPROVE_OPTION){
600            this.vCardFile = new File(chooser.getSelectedFile().getAbsolutePath());
610            logger.debug("vCard file: " + vCardFile); //$NON-NLS-1$
620            setStatus(EXECUTE_STATUS);
630        }else setStatus(ABORT_STATUS);
640    }
65     
660    /*
670     * (non-Javadoc)
680     *
690     * @see ui.command.Command#execution()
700     */
710    @Override
720    protected void execution() throws Exception {
730        switch(getStatus()){
740        case ERROR_STATUS:
750            break;
760        case VETOED_STATUS:
770            break;
780        case EXECUTE_STATUS:
790            JCard jcard = new JCard();
800            Reader fileReader = new FileReader(this.vCardFile);
810            jcard.read(fileReader);
820            fileReader.close();
830            User user = UserFactory.newUser(jcard,"password"); //$NON-NLS-1$
840            InternetCafeManager.getInstance().addUser(user);
850            setStatus(SUCCESS_STATUS);
86             break;
870        }
880    }
890}

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.