1   package com.trendmicro.grid.acl.l0;
2   
3   import org.slf4j.Logger;
4   import org.slf4j.LoggerFactory;
5   
6   import javax.xml.bind.annotation.*;
7   import javax.xml.ws.WebFault;
8   
9   /**
10   * Defines a SOAP fault that is sent as reply for "batch" enabled service methods when the batch size inside the
11   * request exceeds the configured limit.
12   * <p/>
13   * The exception contains the acceptable batch size as {@link #getAllowedBatchSize()} allowing clients to adaptively
14   * choose the right batch size and retry a request that failed on this SOAP fault.
15   *
16   * @author Juergen_Kellerer, 2010-04-26
17   */
18  @XmlAccessorType(XmlAccessType.FIELD)
19  @XmlType(namespace = Level0Constants.NAMESPACE)
20  @WebFault(targetNamespace = Level0Constants.NAMESPACE)
21  public class BatchSizeExceededException extends RuntimeException {
22  
23  	private static final long serialVersionUID = -5854824433574110209L;
24  
25  	private static final Logger log = LoggerFactory.getLogger(BatchSizeExceededException.class);
26  	private static final String DEFAULT_MESSAGE = "This request exceeded the allowed batch size. " +
27  			"Please retry in batches that fit into the allowed batch size.";
28  
29  	@XmlAttribute
30  	private int allowedBatchSize;
31  
32  	@XmlElement
33  	private String message = DEFAULT_MESSAGE;
34  
35  	public BatchSizeExceededException(int allowedBatchSize) {
36  		super(DEFAULT_MESSAGE);
37  		this.allowedBatchSize = allowedBatchSize;
38  
39  		if (log.isTraceEnabled()) {
40  			log.trace("About to throw BatchSizeExceededException, AllowedBatchSize: {}, Message: {}", allowedBatchSize, message);
41  		}
42  	}
43  
44  	public int getAllowedBatchSize() {
45  		return allowedBatchSize;
46  	}
47  }