Line | Hits | Source |
---|---|---|
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; | |
24 | 0 | import java.io.FileReader; |
25 | import java.io.Reader; | |
26 | 0 | |
27 | import org.apache.log4j.Logger; | |
28 | ||
29 | import ui.Messages; | |
30 | 0 | import ui.command.Command; |
31 | import base.InternetCafe; | |
32 | 0 | import base.InternetCafeManager; |
33 | import base.user.User; | |
34 | import base.user.UserFactory; | |
35 | import base.user.jcard.JCard; | |
36 | 0 | |
37 | 0 | public class ImportUserFromVCardCommand extends Command { |
38 | 0 | |
39 | 0 | private static final transient Logger logger = Logger.getLogger(ImportUserFromVCardCommand.class |
40 | 0 | .getName()); |
41 | 0 | private File vCardFile = null; |
42 | 0 | |
43 | 0 | public ImportUserFromVCardCommand() { |
44 | 0 | |
45 | 0 | } |
46 | 0 | |
47 | 0 | /* |
48 | 0 | * (non-Javadoc) |
49 | 0 | * |
50 | 0 | * @see ui.command.Command#prologo() |
51 | 0 | */ |
52 | @Override | |
53 | 0 | protected void prologo() { |
54 | 0 | InternetCafe.setStatusBarMessage(Messages.getString("command.importuserfromvcardcommand.importinguserfromvcard")); //$NON-NLS-1$ |
55 | 0 | javax.swing.JFileChooser chooser = new javax.swing.JFileChooser(); |
56 | 0 | chooser.setDialogTitle(Messages.getString("command.importuserfromvcardcommand.dialog.title")); //$NON-NLS-1$ |
57 | 0 | chooser.setFileSelectionMode(javax.swing.JFileChooser.FILES_ONLY); |
58 | 0 | chooser.setApproveButtonText(Messages.getString("button.select")); //$NON-NLS-1$ |
59 | 0 | if (chooser.showOpenDialog(null) == javax.swing.JFileChooser.APPROVE_OPTION){ |
60 | 0 | this.vCardFile = new File(chooser.getSelectedFile().getAbsolutePath()); |
61 | 0 | logger.debug("vCard file: " + vCardFile); //$NON-NLS-1$ |
62 | 0 | setStatus(EXECUTE_STATUS); |
63 | 0 | }else setStatus(ABORT_STATUS); |
64 | 0 | } |
65 | ||
66 | 0 | /* |
67 | 0 | * (non-Javadoc) |
68 | 0 | * |
69 | 0 | * @see ui.command.Command#execution() |
70 | 0 | */ |
71 | 0 | @Override |
72 | 0 | protected void execution() throws Exception { |
73 | 0 | switch(getStatus()){ |
74 | 0 | case ERROR_STATUS: |
75 | 0 | break; |
76 | 0 | case VETOED_STATUS: |
77 | 0 | break; |
78 | 0 | case EXECUTE_STATUS: |
79 | 0 | JCard jcard = new JCard(); |
80 | 0 | Reader fileReader = new FileReader(this.vCardFile); |
81 | 0 | jcard.read(fileReader); |
82 | 0 | fileReader.close(); |
83 | 0 | User user = UserFactory.newUser(jcard,"password"); //$NON-NLS-1$ |
84 | 0 | InternetCafeManager.getInstance().addUser(user); |
85 | 0 | setStatus(SUCCESS_STATUS); |
86 | break; | |
87 | 0 | } |
88 | 0 | } |
89 | 0 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |