KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > admin > sites > SiteExtractionBean


1 //
2
// ____.
3
// __/\ ______| |__/\. _______
4
// __ .____| | \ | +----+ \
5
// _______| /--| | | - \ _ | : - \_________
6
// \\______: :---| : : | : | \________>
7
// |__\---\_____________:______: :____|____:_____\
8
// /_____|
9
//
10
// . . . i n j a h i a w e t r u s t . . .
11
//
12
//
13
//
14
// SiteExtractionBean
15
//
16
// NK 03.08.2001
17
//
18
//
19

20 package org.jahia.admin.sites;
21
22
23 import java.util.Enumeration JavaDoc;
24 import java.util.Vector JavaDoc;
25
26 import org.jahia.exceptions.JahiaException;
27 import org.jahia.utils.JahiaTools;
28 import org.jahia.utils.properties.PropertiesManager;
29
30
31 /**
32  * Load Information from a site extraction properties file
33  *
34  * @author Khue ng
35  * @version 1.0
36  */

37 public class SiteExtractionBean {
38
39     
40     private static final String JavaDoc CLASS_NAME ="SiteExtractionBean";
41     private String JavaDoc mExtractName;
42     private String JavaDoc mExtractDescr;
43     private long mDate;
44     private int mBuild;
45     private double mRelease;
46
47     /**
48      * @associates SiteInfoBean
49      */

50     private Vector JavaDoc mSites = new Vector JavaDoc();
51
52
53
54     /**
55      * Constructor
56      * @param descrFile, a valid extraction properties file
57      * @exception JahiaException throw when file is not valid
58      */

59     public SiteExtractionBean ( String JavaDoc descrFile ) throws JahiaException {
60         
61         if ( descrFile == null ){
62             throw new JahiaException(CLASS_NAME,
63                                      "Description File path is null",
64                                      JahiaException.ERROR_SEVERITY,
65                                      JahiaException.ERROR_SEVERITY);
66         }
67         
68         PropertiesManager prop = new PropertiesManager(descrFile);
69         
70         mExtractName = prop.getProperty(ExtDepSiteConstants.DESCRFILE_NAME);
71         if ( mExtractName == null
72              || mExtractName.trim().equals("") ){
73             throw new JahiaException(CLASS_NAME,
74                                      "Extraction Name is not valid",
75                                      JahiaException.ERROR_SEVERITY,
76                                      JahiaException.ERROR_SEVERITY);
77         }
78
79         mExtractDescr = prop.getProperty(ExtDepSiteConstants.DESCRFILE_DESCR);
80         if ( mExtractDescr == null ){
81             mExtractDescr = "No description";
82         }
83         
84         try {
85             mDate = Long.parseLong(prop.getProperty(ExtDepSiteConstants.DESCRFILE_DATE));
86         } catch ( Throwable JavaDoc t ){
87             throw new JahiaException(CLASS_NAME,
88                                      "Extraction Date is not valid",
89                                      JahiaException.ERROR_SEVERITY,
90                                      JahiaException.ERROR_SEVERITY);
91         }
92
93         try {
94             mBuild = Integer.parseInt(prop.getProperty(ExtDepSiteConstants.DESCRFILE_BUILD));
95         } catch ( Throwable JavaDoc t ){
96             throw new JahiaException(CLASS_NAME,
97                                      "Extraction Build number is not valid",
98                                      JahiaException.ERROR_SEVERITY,
99                                      JahiaException.ERROR_SEVERITY);
100         }
101
102         try {
103             mRelease = Double.parseDouble(prop.getProperty(ExtDepSiteConstants.DESCRFILE_RELEASE));
104         } catch ( Throwable JavaDoc t ){
105             throw new JahiaException(CLASS_NAME,
106                                      "Extraction Release number is not valid",
107                                      JahiaException.ERROR_SEVERITY,
108                                      JahiaException.ERROR_SEVERITY);
109         }
110
111         try {
112             String JavaDoc[] sites = JahiaTools.getTokens(prop.getProperty(ExtDepSiteConstants.DESCRFILE_SITES),",");
113             for ( int i=0 ; i<sites.length ; i++ ){
114                 String JavaDoc[] site = JahiaTools.getTokens(sites[i],"@@@");
115                 SiteInfoBean sBean = new SiteInfoBean(site[0],site[1]);
116                 mSites.add(sBean);
117             }
118         } catch ( Throwable JavaDoc t ){
119             throw new JahiaException(CLASS_NAME,
120                                      "Extraction Site List is not valid",
121                                      JahiaException.ERROR_SEVERITY,
122                                      JahiaException.ERROR_SEVERITY);
123         }
124                 
125         prop = null;
126     }
127
128
129     //--------------------------------------------------------------------------
130
/**
131      * Returns the extract name
132      */

133     public String JavaDoc getName(){
134         return mExtractName;
135     }
136
137     //--------------------------------------------------------------------------
138
/**
139      * Returns the extract descr
140      */

141     public String JavaDoc getDescr(){
142         return mExtractDescr;
143     }
144
145     //--------------------------------------------------------------------------
146
/**
147      * Returns the extract date
148      */

149     public long getDate(){
150         return mDate;
151     }
152
153     //--------------------------------------------------------------------------
154
/**
155      * Returns the extract build number
156      */

157     public int getBuildNumber(){
158         return mBuild;
159     }
160
161     //--------------------------------------------------------------------------
162
/**
163      * Returns the release number
164      */

165     public double getReleaseNumber(){
166         return mRelease;
167     }
168
169     //--------------------------------------------------------------------------
170
/**
171      * Returns an enumeration of site names contained in this extraction
172      */

173     public Enumeration JavaDoc getSites(){
174         return mSites.elements();
175     }
176     
177 }
Popular Tags