KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > ui > web > admin > services > servicetypes > CustomWorkerType


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 package org.ejbca.ui.web.admin.services.servicetypes;
14
15 import java.io.ByteArrayInputStream JavaDoc;
16 import java.io.ByteArrayOutputStream JavaDoc;
17 import java.io.IOException JavaDoc;
18 import java.util.ArrayList JavaDoc;
19 import java.util.Collection JavaDoc;
20 import java.util.Properties JavaDoc;
21
22 /**
23  * Class used to populate the fields in the customworker.jsp subview page.
24  *
25  * Is comatible with custom action and custom interval.
26  *
27  * @author Philip Vendil 2006 sep 30
28  *
29  * @version $Id: CustomWorkerType.java,v 1.3 2006/10/26 11:02:17 herrvendil Exp $
30  */

31 public class CustomWorkerType extends WorkerType {
32     
33     public static final String JavaDoc NAME = "CUSTOMWORKER";
34     
35     public CustomWorkerType() {
36         super("customworker.jsp", NAME, true);
37         
38         compatibleActionTypeNames.add(CustomActionType.NAME);
39         compatibleActionTypeNames.add(NoActionType.NAME);
40         compatibleActionTypeNames.add(MailActionType.NAME);
41         
42         compatibleIntervalTypeNames.add(CustomIntervalType.NAME);
43         compatibleIntervalTypeNames.add(PeriodicalIntervalType.NAME);
44     }
45
46     private String JavaDoc classPath;
47     private String JavaDoc propertyText;
48     private Collection JavaDoc compatibleActionTypeNames = new ArrayList JavaDoc();
49     private Collection JavaDoc compatibleIntervalTypeNames = new ArrayList JavaDoc();
50
51     /**
52      * @return the propertyText
53      */

54     public String JavaDoc getPropertyText() {
55         return propertyText;
56     }
57
58     /**
59      * @param propertyText the propertyText to set
60      */

61     public void setPropertyText(String JavaDoc propertyText) {
62         this.propertyText = propertyText;
63     }
64
65     /**
66      * @param classPath the classPath to set
67      */

68     public void setClassPath(String JavaDoc classPath) {
69         this.classPath = classPath;
70     }
71
72     public String JavaDoc getClassPath() {
73         return classPath;
74     }
75
76     public Properties JavaDoc getProperties(ArrayList JavaDoc errorMessages) throws IOException JavaDoc{
77         Properties JavaDoc retval = new Properties JavaDoc();
78         retval.load(new ByteArrayInputStream JavaDoc(getPropertyText().getBytes()));
79         return retval;
80     }
81     
82     public void setProperties(Properties JavaDoc properties) throws IOException JavaDoc{
83         ByteArrayOutputStream JavaDoc baos = new ByteArrayOutputStream JavaDoc();
84         properties.store(baos, null);
85         setPropertyText(new String JavaDoc(baos.toByteArray()));
86     }
87     
88     /**
89      * @return the names of the Compatible Action Types
90      */

91     public Collection JavaDoc getCompatibleActionTypeNames() {
92         return compatibleActionTypeNames;
93     }
94
95     /**
96      * @return the names of the Compatible Interval Types
97      */

98     public Collection JavaDoc getCompatibleIntervalTypeNames() {
99         return compatibleIntervalTypeNames;
100     }
101     
102     public boolean isCustom() {
103         return true;
104     }
105
106 }
107
Popular Tags