KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > engines > audit > ManageLogs_Engine


1 //
2
// ____.
3
// __/\ ______| |__/\. _______
4
// __ .____| | \ | +----+ \
5
// _______| /--| | | - \ _ | : - \_________
6
// \\______: :---| : : | : | \________>
7
// |__\---\_____________:______: :____|____:_____\
8
// /_____|
9
//
10
// . . . i n j a h i a w e t r u s t . . .
11
//
12

13 //
14
// ManageLogs_Engine
15
// MJ 27.02.20001
16
//
17
// getInstance()
18
// authoriseRender()
19
// renderLink()
20
// needsJahiaData()
21
// handleActions()
22
//
23

24 package org.jahia.engines.audit;
25
26 import java.util.HashMap JavaDoc;
27
28 import javax.servlet.http.HttpSession JavaDoc;
29
30 import org.jahia.data.JahiaData;
31 import org.jahia.engines.EngineToolBox;
32 import org.jahia.engines.JahiaEngine;
33 import org.jahia.exceptions.JahiaException;
34 import org.jahia.exceptions.JahiaSessionExpirationException;
35 import org.jahia.params.ParamBean;
36
37 public class ManageLogs_Engine {
38
39     /** The engine's name. */
40     public static final String JavaDoc ENGINE_NAME = "audit";
41
42     /** The engine's JSP filename */
43     private static final String JavaDoc TEMPLATE_JSP = "/jsp/jahia/engines/audit/sendlogs.jsp";
44
45     private static ManageLogs_Engine instance = null;
46     private EngineToolBox toolBox;
47
48     /** logging */
49     private static final org.apache.log4j.Logger logger =
50             org.apache.log4j.Logger.getLogger (ManageLogs_Engine.class);
51
52     /**
53      * constructor
54      */

55     private ManageLogs_Engine () {
56         logger.debug (
57                 "***** Starting " + ManageLogs_Engine.class.getName () + " engine *****");
58         toolBox = EngineToolBox.getInstance ();
59     }
60
61
62     /**
63      * returns a single instance of the object
64      */

65     public static synchronized ManageLogs_Engine getInstance () {
66         if (instance == null) {
67             instance = new ManageLogs_Engine ();
68         }
69         return instance;
70     }
71
72
73     /**
74      * authoriseRender
75      */

76     public boolean authoriseRender (ParamBean jParams) {
77         return toolBox.authoriseRender (jParams);
78     }
79
80
81     /**
82      * renderLink no params allowed
83      */

84     public String JavaDoc renderLink (ParamBean jParams, Object JavaDoc theObj)
85             throws JahiaException {
86         return jParams.composeEngineUrl (ENGINE_NAME);
87     }
88
89
90     /**
91      * needsJahiaData
92      */

93     public boolean needsJahiaData (ParamBean jParams) {
94         return false;
95     }
96
97
98     /**
99      * handles the engine actions
100      *
101      * @param jParams a ParamBean object
102      * @param jData a JahiaData object (not mandatory)
103      */

104     public void handleActions (ParamBean jParams, int mode, HashMap JavaDoc engineMap, JahiaData jData)
105             throws JahiaException,
106             JahiaSessionExpirationException {
107         // initalizes the hashmap
108
// HashMap engineMap = initEngineMap (jParams);
109

110         switch (mode) {
111             case (JahiaEngine.LOAD_MODE):
112                 break;
113             case (JahiaEngine.UPDATE_MODE):
114                 break;
115             case (JahiaEngine.SAVE_MODE):
116                 break;
117         }
118
119         // displays the screen
120
// toolBox.displayScreen (jParams, engineMap);
121

122     }
123
124     /**
125      * Retrieve the engine name.
126      *
127      * @return the engine name.
128      */

129     public final String JavaDoc getName () {
130         return ENGINE_NAME;
131     }
132
133
134     /**
135      * inits the engine map
136      *
137      * @param jParams a ParamBean object (with request and response)
138      *
139      * @return a HashMap object containing all the basic values needed by an engine
140      */

141     private HashMap JavaDoc initEngineMap (ParamBean jParams)
142             throws JahiaException,
143             JahiaSessionExpirationException {
144
145         // gets session values
146
//HttpSession theSession = jParams.getRequest().getSession( true );
147
HttpSession JavaDoc theSession = jParams.getSession ();
148
149         HashMap JavaDoc engineMap = (HashMap JavaDoc) theSession.getAttribute ("jahia_session_engineMap");
150
151         ///////////////////////////////////////////////////////////////////////////////////////
152
// FIXME -Fulco-
153
//
154
// This is a quick hack, engineMap should not be null if the session didn't
155
// expired. Maybe there are other cases where the engineMap can be null, I didn't
156
// checked them at all.
157
///////////////////////////////////////////////////////////////////////////////////////
158
if (engineMap == null) {
159             throw new JahiaSessionExpirationException ();
160         }
161
162         engineMap.put (JahiaEngine.RENDER_TYPE_PARAM, new Integer JavaDoc (JahiaEngine.RENDERTYPE_FORWARD));
163         engineMap.put (JahiaEngine.ENGINE_NAME_PARAM, ENGINE_NAME);
164         /*
165         We should only use sendLogs template when we actually request the
166         logs to be sent.
167         engineMap.put (JahiaEngine.ENGINE_OUTPUT_FILE_PARAM, TEMPLATE_JSP);
168         */

169         theSession.setAttribute ("jahia_session_engineMap", engineMap);
170
171
172         // sets engineMap for JSPs
173
jParams.getRequest ().setAttribute ("org.jahia.engines.EngineHashMap", engineMap);
174
175         return engineMap;
176     }
177
178
179 }
180
Popular Tags