KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > ui > web > admin > approval > ApprovalView


1 /*************************************************************************
2  * *
3  * EJBCA: The OpenSource Certificate Authority *
4  * *
5  * This software is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or any later version. *
9  * *
10  * See terms of license at gnu.org. *
11  * *
12  *************************************************************************/

13
14 package org.ejbca.ui.web.admin.approval;
15
16 import java.io.UnsupportedEncodingException JavaDoc;
17 import java.text.DateFormat JavaDoc;
18
19 import javax.ejb.EJBException JavaDoc;
20
21 import org.ejbca.core.model.approval.Approval;
22 import org.ejbca.ui.web.admin.configuration.EjbcaJSFHelper;
23 import org.ejbca.ui.web.admin.configuration.EjbcaWebBean;
24
25 /**
26  * Class used to represent the view of an approval
27  *
28  * @author Philip Vendil
29  * @version $Id: ApprovalView.java,v 1.2 2006/09/05 09:23:28 anatom Exp $
30  */

31 public class ApprovalView {
32     
33     private Approval approval;
34     
35     public ApprovalView(Approval approval){
36         this.approval=approval;
37     }
38     
39
40     public Approval getApproval() {
41         return approval;
42     }
43     
44     public String JavaDoc getApprovalDate(){
45         DateFormat JavaDoc dateformat = DateFormat.getDateTimeInstance();
46         return dateformat.format(approval.getApprovalDate());
47     }
48     
49     public String JavaDoc getApprovalAdmin(){
50         return approval.getUsername();
51     }
52     
53     public String JavaDoc getAdminAction(){
54         EjbcaWebBean ejbcawebbean = EjbcaJSFHelper.getBean().getEjbcaWebBean();
55         
56         if(approval.isApproved()){
57             return ejbcawebbean.getText("APPROVED");
58         }
59         return ejbcawebbean.getText("REJECTED");
60     }
61     
62     public String JavaDoc getViewApproverCertLink(){
63         String JavaDoc link;
64         try {
65             link = EjbcaJSFHelper.getBean().getEjbcaWebBean().getBaseUrl() + EjbcaJSFHelper.getBean().getEjbcaWebBean().getGlobalConfiguration().getAdminWebPath()
66                         + "viewcertificate.jsp?certsernoparameter=" + java.net.URLEncoder.encode(approval.getAdminCertSerialNumber().toString(16) + "," + approval.getAdminCertIssuerDN(),"UTF-8");
67         } catch (UnsupportedEncodingException JavaDoc e) {
68             throw new EJBException JavaDoc(e);
69         }
70         
71         return "viewcert('" + link + "')";
72     }
73     
74     public String JavaDoc getComment(){
75         return approval.getComment();
76     }
77 }
78
Popular Tags