1 23 24 package com.sun.enterprise.config.serverbeans.validation; 25 26 import com.sun.enterprise.config.serverbeans.validation.tests.StaticTest; 27 import java.io.File ; 28 29 41 42 43 44 public class AttrFile extends AttrType { 45 46 boolean checkExists; 47 48 public AttrFile(String name, String type, boolean optional) { 49 super(name,type, optional); 50 checkExists = false; 51 } 52 53 public void setCheckExists(boolean flag) { 54 checkExists = flag; 55 } 56 57 public void validate(Object o, ValidationContext valCtx) { 58 super.validate(o, valCtx); if(o == null || o.equals("")) 60 return; 61 if(checkExists || StaticTest.fileCheck) { 62 File f = new File ((String )o); 63 if(!f.exists()) 64 valCtx.result.failed(valCtx.smh.getLocalString(getClass().getName() + ".fileNotExists", 65 "Attribute({0}={1}) : {2} : Does not exists", new Object [] {valCtx.attrName, o, o})); 66 else if(!f.canRead()) 67 valCtx.result.failed(valCtx.smh.getLocalString(getClass().getName() + ".filecannotRead", 68 "Attribute({0}={1}) : {2} : Does not have read permission", new Object [] {valCtx.attrName, o, o})); 69 } 70 } 71 } 72 | Popular Tags |