1 19 20 package com.sslexplorer.input.validators; 21 22 import java.io.File ; 23 import java.util.Properties ; 24 25 import org.apache.commons.logging.Log; 26 import org.apache.commons.logging.LogFactory; 27 28 import com.sslexplorer.boot.CodedException; 29 import com.sslexplorer.boot.PropertyClassManager; 30 import com.sslexplorer.boot.PropertyDefinition; 31 import com.sslexplorer.boot.PropertyValidator; 32 import com.sslexplorer.core.CoreException; 33 import com.sslexplorer.properties.impl.profile.ProfileProperties; 34 35 41 public class ThemeValidator extends NonBlankStringValidator { 42 43 final static Log log = LogFactory.getLog(ThemeValidator.class); 44 45 49 public ThemeValidator() { 50 super(); 51 } 52 53 59 public void validate(PropertyDefinition definition, String value, Properties properties) throws CodedException { 60 try { 61 super.validate(definition, value, properties); 62 } catch (CoreException ce) { 63 throw new CoreException(ErrorConstants.ERR_EMPTY_THEME, 64 ErrorConstants.CATEGORY_NAME, 65 ErrorConstants.BUNDLE_NAME, 66 null, 67 value, 68 PropertyClassManager.getInstance() 69 .getPropertyClass(ProfileProperties.NAME) 70 .getDefinition("ui.theme") 71 .getDefaultValue(), 72 null, 73 null); 74 } 75 File themeDirectory = new File (new File ("webapp"), value.replace('/', File.separatorChar).replace('\\', File.separatorChar)); 76 if (!themeDirectory.isDirectory()) { 77 throw new CoreException(ErrorConstants.ERR_INVALID_THEME, 78 ErrorConstants.CATEGORY_NAME, 79 ErrorConstants.BUNDLE_NAME, 80 null, 81 value); 82 } 83 } 84 85 } 86 | Popular Tags |