1 package net.sf.provisioner.requests;
2
3 import net.sf.provisioner.responses.Response;
4
5 /**
6 * A request that performs no operation when {@linkplain sendRequest} is
7 * called, then returns a response object with a custom error message.
8 * The message typically details user configuration errors (e.g. no network
9 * element name specified.)
10 *
11 * @author g_pearson
12 * @version $Revision: 1 $
13 * @created Nov 14, 2007
14 */
15 public class FailedRequest extends Request {
16
17 private String errorMessage;
18
19 /**
20 * Creates a FailedRequest with a custom error message.
21 * @param the human-readable reason for the request's failure.
22 */
23 public FailedRequest(String errorMessage) {
24 this.errorMessage = errorMessage;
25 }
26
27 /**
28 * Returns a failed response containing the error message passed to the
29 * constructor.
30 */
31 @Override
32 public Response sendRequest() throws Exception {
33 Response response = new Response();
34 response.result =
35 response.errorStr = errorMessage;
36 response.retry = false;
37 response.successfull = false;
38 return response;
39 }
40 }