01: package vqwiki.servlets;
02:
03: import vqwiki.Topic;
04: import vqwiki.WikiBase;
05: import vqwiki.WikiException;
06: import vqwiki.utils.Utilities;
07:
08: import javax.servlet.ServletException;
09: import javax.servlet.http.HttpServletRequest;
10: import javax.servlet.http.HttpServletResponse;
11: import java.io.IOException;
12:
13: /**
14: * @author garethc
15: * Date: Jan 8, 2003
16: */
17: public class AttachServlet extends VQWikiServlet {
18:
19: /**
20: *
21: */
22: protected void doGet(HttpServletRequest request,
23: HttpServletResponse response) throws ServletException,
24: IOException {
25: String topic = request.getParameter("topic");
26: request.setAttribute("title", "Attach Files to " + topic);
27: request.setAttribute("topic", topic);
28: String virtualWiki = (String) request
29: .getAttribute("virtualWiki");
30: String user = request.getRemoteAddr();
31: if (Utilities.getUserFromRequest(request) != null) {
32: user = Utilities.getUserFromRequest(request);
33: }
34: request.setAttribute("user", user);
35: try {
36: Topic t = new Topic(topic);
37: if (t.isReadOnlyTopic(virtualWiki)) {
38: error(request, response, new WikiException(
39: WikiException.READ_ONLY));
40: return;
41: }
42: if (topic == null || topic.equals("")) {
43: throw new WikiException("Topic must be specified");
44: }
45: WikiBase base = WikiBase.getInstance();
46: String key = request.getSession().getId();
47: if (!base.lockTopic(virtualWiki, topic, key)) {
48: throw new WikiException(WikiException.TOPIC_LOCKED);
49: }
50: } catch (Exception e) {
51: error(request, response, e);
52: return;
53: }
54: dispatch("/jsp/attach.jsp", request, response);
55: }
56: }
|