01: package dalma.webui;
02:
03: import org.kohsuke.stapler.StaplerRequest;
04: import org.kohsuke.stapler.StaplerResponse;
05:
06: import javax.servlet.ServletException;
07: import java.io.IOException;
08: import java.util.logging.LogRecord;
09: import java.util.List;
10: import java.util.Collections;
11:
12: /**
13: * @author Kohsuke Kawaguchi
14: */
15: public abstract class UIObject {
16: /**
17: * Returns the name used in the top breadcrumb.
18: */
19: public abstract String getDisplayName();
20:
21: /**
22: * Returns the URL of this object.
23: */
24: public abstract String getUrl();
25:
26: /**
27: * Optional method to return log entries associated with this object, if any.
28: */
29: public List<LogRecord> getLogs() {
30: return Collections.emptyList();
31: }
32:
33: protected final void sendError(StaplerRequest req, String msg,
34: StaplerResponse resp) throws ServletException, IOException {
35: req.setAttribute("message", msg);
36: resp.forward(this , "error", req);
37: }
38:
39: protected final void sendError(StaplerRequest req, Exception e,
40: StaplerResponse resp) throws ServletException, IOException {
41: req.setAttribute("message", e.getMessage());
42: req.setAttribute("exception", e);
43: resp.forward(this , "error", req);
44: }
45: }
|