Coverage details for base.jdbs.ui.command.BuildBackupArtifactCommand

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 base.jdbs.ui.command;
22  
23 import java.security.KeyStore;
24 import java.util.Enumeration;
25  
26 import org.apache.log4j.Logger;
27  
28 import ui.command.Command;
29 import base.InternetCafe;
30 import base.jdbs.Backup;
31 import base.jdbs.BackupArtifactAssembler;
32 import base.jdbs.ConfigurationManager;
33 import base.jdbs.cryptography.asymmetric.AsymmetricKeyRing;
34 import base.jdbs.cryptography.symmetric.SymmetricKey;
35  
36 /**
37  * @author skunk
38  *
39  */
400public class BuildBackupArtifactCommand extends Command {
41  
420    private static final transient Logger logger = Logger.getLogger(BuildBackupArtifactCommand.class.getName());
43  
44     private final Backup backup;
45     
460    public BuildBackupArtifactCommand(Backup backup){
470        this.backup = backup;
480    }
49     
50     /*
51      * (non-Javadoc)
52      *
53      * @see ui.command.Command#prologo()
54      */
55     @Override
56     protected void prologo() {
570        InternetCafe.setStatusBarMessage("Building a new backup...");
580        setStatus(EXECUTE_STATUS);
590    }
60  
61     /*
62      * (non-Javadoc)
63      *
64      * @see ui.command.Command#execution()
65      */
66     @Override
67     protected void execution() throws Exception {
680        switch (getStatus()) {
69         case ABORT_STATUS:
700            break;
71         case VETOED_STATUS:
720            break;
73         case EXECUTE_STATUS:
74             try{
750                AsymmetricKeyRing asymmetricKeyRing = new AsymmetricKeyRing(ConfigurationManager.getInstance().getUser());
76             
770                KeyStore keyStore = asymmetricKeyRing.retrieve(ConfigurationManager.getInstance().getKeyRingLocation(),"password");
780                Enumeration aliasEnumeration = keyStore.aliases();
790                while(aliasEnumeration.hasMoreElements()){
800                    System.out.println(aliasEnumeration.nextElement());
810                }
820                long start = System.currentTimeMillis();
830                BackupArtifactAssembler.buildNewBackupArtifact(ConfigurationManager.getInstance().getRepository().getLocation(),new SymmetricKey("password"),asymmetricKeyRing.getAllKeyPair()[0],backup);
840                long end = System.currentTimeMillis();
850                logger.debug("The backup artifact assemblation has taken: "+(end - start)+" ms");
860                ConfigurationManager.getInstance().getRepository().indexRepository();
870            }catch(Exception ex){
880                ex.printStackTrace();
890            }
90             
910            setStatus(SUCCESS_STATUS);
92             break;
93         }
940    }
95  
96     /*
97      * (non-Javadoc)
98      *
99      * @see ui.command.Command#epilogue()
100      */
101     @Override
102     protected void epilogue() {
1030        switch (getStatus()) {
104         case SUCCESS_STATUS:
1050            InternetCafe.setStatusBarMessage("Backup successfully created...");
1060            break;
107         case ABORT_STATUS:
1080            InternetCafe.setStatusBarMessage("Command aborted by user...");
1090            break;
110         case ERROR_STATUS:
1110            InternetCafe.setStatusBarMessage("Command error...");
1120            break;
113         case VETOED_STATUS:
1140            InternetCafe.setStatusBarMessage("Command vetoed...");
115             break;
116         }
1170    }
118  
119 }
120  

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.