1 20 package org.jahia.admin.sites; 21 22 23 import java.util.Enumeration ; 24 import java.util.Vector ; 25 26 import org.jahia.exceptions.JahiaException; 27 import org.jahia.utils.JahiaTools; 28 import org.jahia.utils.properties.PropertiesManager; 29 30 31 37 public class SiteExtractionBean { 38 39 40 private static final String CLASS_NAME ="SiteExtractionBean"; 41 private String mExtractName; 42 private String mExtractDescr; 43 private long mDate; 44 private int mBuild; 45 private double mRelease; 46 47 50 private Vector mSites = new Vector (); 51 52 53 54 59 public SiteExtractionBean ( String 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 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 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 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 [] sites = JahiaTools.getTokens(prop.getProperty(ExtDepSiteConstants.DESCRFILE_SITES),","); 113 for ( int i=0 ; i<sites.length ; i++ ){ 114 String [] site = JahiaTools.getTokens(sites[i],"@@@"); 115 SiteInfoBean sBean = new SiteInfoBean(site[0],site[1]); 116 mSites.add(sBean); 117 } 118 } catch ( Throwable 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 133 public String getName(){ 134 return mExtractName; 135 } 136 137 141 public String getDescr(){ 142 return mExtractDescr; 143 } 144 145 149 public long getDate(){ 150 return mDate; 151 } 152 153 157 public int getBuildNumber(){ 158 return mBuild; 159 } 160 161 165 public double getReleaseNumber(){ 166 return mRelease; 167 } 168 169 173 public Enumeration getSites(){ 174 return mSites.elements(); 175 } 176 177 } | Popular Tags |