KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > webEditor > interfaces > compositionMode


1 /* $Id: compositionMode.java,v 1.13 2001/04/23 03:15:31 agarcia3 Exp $
2     webEditor. The new way in content management
3     Copyright (C) 2001 Alfredo Garcia
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12     GNU General Public License for more details.
13 */

14
15 package webEditor.interfaces;
16
17 import java.io.*;
18 import java.lang.reflect.*;
19
20 import javax.servlet.*;
21 import javax.servlet.http.*;
22 import org.w3c.dom.*;
23
24 import webEditor.core.*;
25
26 /**
27  * HomePage interface; This class manage all the composition operations
28  * @author <a HREF="mailto:agarcia@mundofree.com">Alfredo Garcia</a>
29  */

30
31 public class compositionMode {
32
33    /**
34     * Initial configuration values
35     */

36    private configuration initValues;
37
38    /**
39     * Presentation management
40     */

41    private presentation myEditor= null;
42
43    /**
44     * HomePage management
45     */

46    private page myDocument= null;
47
48     /**
49      * Class constructor
50      * @param initParam Initial values
51      */

52     public compositionMode (configuration initParam) {
53         // We are going to use the values in the hash table when we
54
// create another kind of core object
55
this.initValues = initParam;
56     }
57     
58     /**
59      * Interface for the presentation operations
60      * @param request HTTP request
61      * @param out Servlet Output
62      * @return void
63      */

64     public void presentation (HttpServletRequest request, PrintWriter out)
65     throws ServletException,
66            IOException {
67
68     this.myEditor = new presentation (this.initValues);
69     this.myDocument = new page (this.initValues);
70
71     String JavaDoc opCode = this.initValues.readValue ("HTTP Parameters", "code");
72
73     if (opCode != null) {
74 try {
75     // We use reflection to invoque the proper method
76
Method m = getClass().getMethod(opCode, new Class JavaDoc[0]);
77     m.invoke(this,new Object JavaDoc[0]);
78 }
79 catch (Exception JavaDoc e) {
80     out.println ("Code not supported");
81 }
82     }
83
84     Document indexDoc = this.myDocument.homePageList ();
85
86     String JavaDoc outputString = this.myEditor.showIndex (indexDoc,"edit");
87     out.println (outputString);
88     }
89
90    /**
91     * Delete the document from the homePage
92     * @return void
93     */

94     public void delete ()
95     throws ServletException, IOException
96     {
97     String JavaDoc docID = this.initValues.readValue ("HTTP Parameters", "docID");
98     if (docID != null) {
99         this.myDocument.removeDoc (docID);
100     }
101     }
102
103    /**
104     * Rises the given document
105     * @return void
106     */

107     public void rise ()
108     throws ServletException, IOException
109     {
110     String JavaDoc docID = this.initValues.readValue ("HTTP Parameters", "docID");
111     if (docID != null) {
112         this.myDocument.riseDoc (docID);
113     }
114     }
115
116    /**
117     * Lowers the given document
118     * @return void
119     */

120     public void lower ()
121     throws ServletException, IOException
122     {
123     String JavaDoc docID = this.initValues.readValue ("HTTP Parameters", "docID");
124     if (docID != null) {
125         this.myDocument.lowerDoc (docID);
126     }
127     }
128
129    /**
130     * Publish the given Home Page
131     * @return void
132     */

133     public void publish ()
134     throws ServletException, IOException
135     {
136         Document indexDoc = this.myDocument.homePageList ();
137
138     String JavaDoc outputString = this.myEditor.showIndex (indexDoc,"presentation");
139     if ( outputString != null ) {
140         this.myDocument.saveHtmlFile (outputString);
141     }
142     }
143
144
145 }
146
Popular Tags