1 23 24 package org.infoglue.cms.util; 25 26 import java.util.Iterator ; 27 28 import org.infoglue.cms.exception.AccessConstraintException; 29 30 31 34 35 public class AccessConstraintExceptionBuffer extends ConstraintExceptionBuffer 36 { 37 40 public AccessConstraintExceptionBuffer() {} 41 42 43 49 50 public final void add(AccessConstraintException exception) { 51 if(exception != null) { 52 final String fieldName = exception.getFieldName(); 54 final String errorCode = exception.getErrorCode(); 55 AccessConstraintException ce = new AccessConstraintException(fieldName, errorCode); 56 this.exceptions.add(ce); 57 add(exception.getChainedException()); 58 } 59 } 60 61 66 public void throwIfNotEmpty() throws AccessConstraintException { 67 if(!isEmpty()) { 68 throw toAccessConstraintException(); 69 } 70 } 71 72 77 public AccessConstraintException toAccessConstraintException() 78 { 79 AccessConstraintException rootException = null; 80 try 81 { 82 83 for(Iterator iterator = this.exceptions.iterator(); iterator.hasNext(); ) 84 { 85 AccessConstraintException ce = (AccessConstraintException) iterator.next(); 86 ce.setChainedException(rootException); 87 rootException = ce; 88 } 89 } 90 catch(Exception e) 91 { 92 e.printStackTrace(); 93 } 94 return rootException; 95 } 96 } | Popular Tags |