KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > core > ejb > log > LocalLogSessionBean


1 /*************************************************************************
2  * *
3  * EJBCA: The OpenSource Certificate Authority *
4  * *
5  * This software is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or any later version. *
9  * *
10  * See terms of license at gnu.org. *
11  * *
12  *************************************************************************/

13
14 package org.ejbca.core.ejb.log;
15
16 import java.io.InputStream JavaDoc;
17 import java.lang.reflect.Method JavaDoc;
18 import java.security.cert.X509Certificate JavaDoc;
19 import java.sql.Connection JavaDoc;
20 import java.sql.PreparedStatement JavaDoc;
21 import java.sql.ResultSet JavaDoc;
22 import java.util.ArrayList JavaDoc;
23 import java.util.Collection JavaDoc;
24 import java.util.Date JavaDoc;
25 import java.util.Iterator JavaDoc;
26 import java.util.Properties JavaDoc;
27
28 import javax.ejb.CreateException JavaDoc;
29 import javax.ejb.EJBException JavaDoc;
30 import javax.ejb.FinderException JavaDoc;
31
32 import org.apache.commons.lang.StringUtils;
33 import org.ejbca.core.ejb.BaseSessionBean;
34 import org.ejbca.core.ejb.JNDINames;
35 import org.ejbca.core.ejb.ca.sign.ISignSessionLocal;
36 import org.ejbca.core.ejb.ca.sign.ISignSessionLocalHome;
37 import org.ejbca.core.ejb.protect.TableProtectSessionLocal;
38 import org.ejbca.core.ejb.protect.TableProtectSessionLocalHome;
39 import org.ejbca.core.model.InternalResources;
40 import org.ejbca.core.model.ca.caadmin.CADoesntExistsException;
41 import org.ejbca.core.model.ca.caadmin.extendedcaservices.CmsCAServiceRequest;
42 import org.ejbca.core.model.ca.caadmin.extendedcaservices.CmsCAServiceResponse;
43 import org.ejbca.core.model.ca.caadmin.extendedcaservices.ExtendedCAServiceNotActiveException;
44 import org.ejbca.core.model.ca.caadmin.extendedcaservices.ExtendedCAServiceRequestException;
45 import org.ejbca.core.model.ca.caadmin.extendedcaservices.IllegalExtendedCAServiceRequestException;
46 import org.ejbca.core.model.log.Admin;
47 import org.ejbca.core.model.log.ILogDevice;
48 import org.ejbca.core.model.log.ILogExporter;
49 import org.ejbca.core.model.log.LogConfiguration;
50 import org.ejbca.core.model.log.LogConstants;
51 import org.ejbca.core.model.log.LogEntry;
52 import org.ejbca.core.model.protect.TableVerifyResult;
53 import org.ejbca.util.CertTools;
54 import org.ejbca.util.JDBCUtil;
55 import org.ejbca.util.query.IllegalQueryException;
56 import org.ejbca.util.query.Query;
57
58
59 /**
60  * Stores data used by web server clients.
61  * Uses JNDI name for datasource as defined in env 'Datasource' in ejb-jar.xml.
62  *
63  *
64  * @ejb.bean
65  * display-name="LogSessionSB"
66  * name="LogSession"
67  * jndi-name="LogSession"
68  * local-jndi-name="LogSessionLocal"
69  * view-type="both"
70  * type="Stateless"
71  * transaction-type="Container"
72  *
73  * @weblogic.enable-call-by-reference True
74  *
75  * @ejb.env-entry
76  * name="DataSource"
77  * type="java.lang.String"
78  * value="${datasource.jndi-name-prefix}${datasource.jndi-name}"
79  *
80  * @ejb.env-entry
81  * description="String representing the log device factories to be used. The different device classes should be separated with semicolons (;)."
82  * name="logDeviceFactories"
83  * type="java.lang.String"
84  * value="org.ejbca.core.model.log.Log4jLogDeviceFactory"
85  *
86  * @ejb.env-entry
87  * description="String representing the property file corresponding to each log device.
88  The property files should be placed in the '/logdeviceproperties' subdirectory.
89  The filenames should be separated with semicolons (;)"
90  * name="logDevicePropertyFiles"
91  * type="java.lang.String"
92  * value="Log4j.properties"
93  *
94  * @ejb.env-entry description="Enable or disable protection of logs, see HOWTO-logsigning.txt"
95  * name="logSigning"
96  * type="java.lang.String"
97  * value="${protection.logprotect}"
98  *
99  * @ejb.ejb-external-ref
100  * description="The Log Entry Data entity bean"
101  * view-type="local"
102  * ref-name="ejb/LogEntryDataLocal"
103  * type="Entity"
104  * home="org.ejbca.core.ejb.log.LogEntryDataLocalHome"
105  * business="org.ejbca.core.ejb.log.LogEntryDataLocal"
106  * link="LogEntryData"
107  *
108  * @ejb.ejb-external-ref
109  * description="The Log Configuration Data Entity bean"
110  * view-type="local"
111  * ref-name="ejb/LogConfigurationDataLocal"
112  * type="Entity"
113  * home="org.ejbca.core.ejb.log.LogConfigurationDataLocalHome"
114  * business="org.ejbca.core.ejb.log.LogConfigurationDataLocal"
115  * link="LogConfigurationData"
116  *
117  * @ejb.ejb-external-ref
118  * description="The table protection session bean"
119  * view-type="local"
120  * ref-name="ejb/TableProtectSessionLocal"
121  * type="Session"
122  * home="org.ejbca.core.ejb.protect.TableProtectSessionLocalHome"
123  * business="org.ejbca.core.ejb.protect.TableProtectSessionLocal"
124  * link="TableProtectSession"
125  *
126  * @ejb.ejb-external-ref description="The Sign Session Bean"
127  * view-type="local"
128  * ref-name="ejb/RSASignSessionLocal"
129  * type="Session"
130  * home="org.ejbca.core.ejb.ca.sign.ISignSessionLocalHome"
131  * business="org.ejbca.core.ejb.ca.sign.ISignSessionLocal"
132  * link="RSASignSession"
133  *
134  * @ejb.home
135  * extends="javax.ejb.EJBHome"
136  * local-extends="javax.ejb.EJBLocalHome"
137  * local-class="org.ejbca.core.ejb.log.ILogSessionLocalHome"
138  * remote-class="org.ejbca.core.ejb.log.ILogSessionHome"
139  *
140  * @ejb.interface
141  * extends="javax.ejb.EJBObject"
142  * local-extends="javax.ejb.EJBLocalObject"
143  * local-class="org.ejbca.core.ejb.log.ILogSessionLocal"
144  * remote-class="org.ejbca.core.ejb.log.ILogSessionRemote"
145  *
146  * @jonas.bean
147  * ejb-name="LogSession"
148  *
149  * @version $Id: LocalLogSessionBean.java,v 1.16.2.2 2007/03/21 15:46:17 anatom Exp $
150  */

151 public class LocalLogSessionBean extends BaseSessionBean {
152
153     /** Internal localization of logs and errors */
154     private static final InternalResources intres = InternalResources.getInstance();
155
156     /** The home interface of LogEntryData entity bean */
157     private LogEntryDataLocalHome logentryhome;
158
159     /** The come interface of the protection session bean */
160     private TableProtectSessionLocalHome protecthome;
161     
162     /** The home interface of LogConfigurationData entity bean */
163     private LogConfigurationDataLocalHome logconfigurationhome;
164
165     /** The home interface of SignSession session bean */
166     private ISignSessionLocalHome signsessionhome;
167
168     /** The remote interface of the LogConfigurationData entity bean */
169     private LogConfigurationDataLocal logconfigurationdata;
170
171     private static final String JavaDoc LOGDEVICE_FACTORIES = "java:comp/env/logDeviceFactories";
172     private static final String JavaDoc LOGDEVICE_PROPERTIES = "java:comp/env/logDevicePropertyFiles";
173     private static final String JavaDoc LOGSIGNING_PROPERTIES = "java:comp/env/logSigning";
174
175     /** Collection of available log devices, i.e Log4j etc */
176     private ArrayList JavaDoc logdevices;
177     /** If signing of logs is enabled of not, default not */
178     private boolean logsigning = false;
179
180     /** Columns in the database used in select */
181     private final String JavaDoc LOGENTRYDATA_TABLE = "LogEntryData";
182     private final String JavaDoc LOGENTRYDATA_COL = "id, adminType, adminData, caid, module, time, username, certificateSNR, event";
183     // Different column names is an unforturnalte workaround because of Orcale, you cannot have a column named 'comment' in Oracle.
184
// The workaround 'comment_' was spread in the wild in 2005, so we have to use it so far.
185
private final String JavaDoc LOGENTRYDATA_COL_COMMENT_OLD = "comment";
186     private final String JavaDoc LOGENTRYDATA_COL_COMMENT_ORA = "comment_";
187
188     /**
189      * Default create for SessionBean without any creation Arguments.
190      */

191     public void ejbCreate() {
192         try {
193             logentryhome = (LogEntryDataLocalHome) getLocator().getLocalHome(LogEntryDataLocalHome.COMP_NAME);
194             logconfigurationhome = (LogConfigurationDataLocalHome) getLocator().getLocalHome(LogConfigurationDataLocalHome.COMP_NAME);
195             signsessionhome = (ISignSessionLocalHome) getLocator().getLocalHome(ISignSessionLocalHome.COMP_NAME);
196
197             // Setup Connection to signing devices.
198
logdevices = new ArrayList JavaDoc();
199
200             // Get configuration of log device classes from ejb-jar.xml
201
String JavaDoc factoryclassesstring = getLocator().getString(LOGDEVICE_FACTORIES);
202             String JavaDoc propertyfilesstring = getLocator().getString(LOGDEVICE_PROPERTIES);
203             String JavaDoc sign = getLocator().getString(LOGSIGNING_PROPERTIES);
204             if (StringUtils.equalsIgnoreCase(sign, "true")) {
205                 logsigning = true;
206                 protecthome = (TableProtectSessionLocalHome) getLocator().getLocalHome(TableProtectSessionLocalHome.COMP_NAME);
207             }
208
209             String JavaDoc[] propertyfiles = propertyfilesstring.split(";");
210             Properties JavaDoc[] properties = new Properties JavaDoc[propertyfiles.length];
211             for (int i = 0; i < propertyfiles.length; i++) {
212                 properties[i] = new Properties JavaDoc();
213                 if (!(propertyfiles[i] == null || propertyfiles[i].trim().equals(""))) {
214                     InputStream JavaDoc is = null;
215                     try {
216                         is = this.getClass().getResourceAsStream("/logdeviceproperties/" + propertyfiles[i].trim());
217                         properties[i].load(is);
218                     } finally {
219                         if (is != null) is.close();
220                     }
221                 }
222             }
223
224             String JavaDoc[] factoryclasses = factoryclassesstring.split(";");
225             for (int i = 0; i < factoryclasses.length; i++) {
226                 Class JavaDoc implClass = Class.forName(factoryclasses[i].trim());
227                 Object JavaDoc fact = implClass.newInstance();
228                 Class JavaDoc[] paramTypes = new Class JavaDoc[]{properties[0].getClass()};
229                 Method JavaDoc method = implClass.getMethod("makeInstance", paramTypes);
230                 Object JavaDoc[] params = new Object JavaDoc[1];
231                 if (i < properties.length)
232                     params[0] = properties[i];
233                 else
234                     params[0] = new Properties JavaDoc();
235                 logdevices.add(method.invoke(fact, params));
236             }
237         } catch (Exception JavaDoc e) {
238             throw new EJBException JavaDoc(e);
239         }
240     }
241
242     /**
243      * Session beans main function. Takes care of the logging functionality.
244      *
245      * @param admin the administrator performing the event.
246      * @param time the time the event occured.
247      * @param username the name of the user involved or null if no user is involved.
248      * @param certificate the certificate involved in the event or null if no certificate is involved.
249      * @param event id of the event, should be one of the org.ejbca.core.model.log.LogEntry.EVENT_ constants.
250      * @param comment comment of the event.
251      *
252      * @ejb.interface-method view-type="both"
253      * @ejb.transaction type="RequiresNew"
254      */

255     public void log(Admin admin, int caid, int module, Date JavaDoc time, String JavaDoc username, X509Certificate JavaDoc certificate, int event, String JavaDoc comment) {
256         doLog(admin, caid, module, time, username, certificate, event, comment, null);
257     } // log
258

259     /**
260      * Same as above but with the difference of CAid which is taken from the issuerdn of given certificate.
261      *
262      * @ejb.interface-method view-type="both"
263      * @ejb.transaction type="RequiresNew"
264      */

265     public void log(Admin admin, X509Certificate JavaDoc caid, int module, Date JavaDoc time, String JavaDoc username, X509Certificate JavaDoc certificate, int event, String JavaDoc comment) {
266         log(admin, CertTools.getIssuerDN(caid).hashCode(), module, time, username, certificate, event, comment);
267     } // log
268

269     /**
270      * Overloaded function that also logs an exception
271      * See function above for more documentation.
272      *
273      * @param exception the exception that has occured
274      *
275      * @ejb.interface-method view-type="both"
276      * @ejb.transaction type="RequiresNew"
277      *
278      */

279     public void log(Admin admin, int caid, int module, Date JavaDoc time, String JavaDoc username, X509Certificate JavaDoc certificate, int event, String JavaDoc comment, Exception JavaDoc exception) {
280         doLog(admin, caid, module, time, username, certificate, event, comment, exception);
281     }
282
283     /**
284      * Same as above but with the difference of CAid which is taken from the issuerdn of given certificate.
285      *
286      * @ejb.interface-method view-type="both"
287      * @ejb.transaction type="RequiresNew"
288      */

289     public void log(Admin admin, X509Certificate JavaDoc caid, int module, Date JavaDoc time, String JavaDoc username, X509Certificate JavaDoc certificate, int event, String JavaDoc comment, Exception JavaDoc exception) {
290         log(admin, CertTools.getIssuerDN(caid).hashCode(), module, time, username, certificate, event, comment, exception);
291     } // log
292

293
294     /**
295      * Internal implementation for logging
296      */

297     private synchronized void doLog(Admin admin, int caid, int module, Date JavaDoc time, String JavaDoc username, X509Certificate JavaDoc certificate, int event, String JavaDoc comment, Exception JavaDoc ex) {
298         final LogConfiguration config = loadLogConfiguration(caid);
299         if (config.logEvent(event)) {
300             try {
301                 if (config.useLogDB()) {
302                     logDB(admin, caid, module, time, username, certificate, event, comment);
303                 }
304             } finally {
305                 // make sure to log here if the db fails
306
if (config.useExternalLogDevices()) {
307                     logExternal(admin, caid, module, time, username, certificate, event, comment, ex);
308                 }
309             }
310         }
311     }
312
313     /**
314      * Make use of the external loggers
315      */

316     private void logExternal(Admin admin, int caid, int module, Date JavaDoc time, String JavaDoc username, X509Certificate JavaDoc certificate, int event, String JavaDoc comment, Exception JavaDoc ex) {
317         Iterator JavaDoc i = logdevices.iterator();
318         while (i.hasNext()) {
319             ILogDevice dev = (ILogDevice) i.next();
320             dev.log(admin, caid, module, time, username, certificate, event, comment, ex);
321         }
322     }
323
324     /**
325      * Log everything in the database using the log entity bean
326      */

327     private void logDB(Admin admin, int caid, int module, Date JavaDoc time, String JavaDoc username, X509Certificate JavaDoc certificate, int event, String JavaDoc comment) {
328         try {
329             String JavaDoc uid = certificate == null ? null : certificate.getSerialNumber().toString(16) + "," + certificate.getIssuerDN().toString();
330             Integer JavaDoc id = getAndIncrementRowCount();
331             logentryhome.create(id, admin.getAdminType(), admin.getAdminData(), caid, module, time, username, uid, event, comment);
332             if (logsigning) {
333                 LogEntry le = new LogEntry(id.intValue(), admin.getAdminType(), admin.getAdminData(), caid, module, time, username, uid, event, comment);
334                 TableProtectSessionLocal protect = protecthome.create();
335                 protect.protect(admin, le);
336             }
337         } catch (Throwable JavaDoc e) {
338             // FIXME we are losing a db audit entry in this case, what do we do ?
339
String JavaDoc msg = intres.getLocalizedMessage("log.errormissingentry");
340             log.error(msg, e);
341             getAndIncrementRowCount();
342         }
343     }
344
345     /**
346      * Method to export log records according to a customized query on the log db data. The parameter query should be a legal Query object.
347      *
348      * @param query a number of statments compiled by query class to a SQL 'WHERE'-clause statment.
349      * @param viewlogprivileges is a sql query string returned by a LogAuthorization object.
350      * @param logexporter is the obbject that converts the result set into the desired log format
351      * @return an exported byte array. Maximum number of exported entries is defined i LogConstants.MAXIMUM_QUERY_ROWCOUNT, returns null if there is nothing to export
352      * @throws IllegalQueryException when query parameters internal rules isn't fullfilled.
353      * @throws ExtendedCAServiceNotActiveException
354      * @throws IllegalExtendedCAServiceRequestException
355      * @throws ExtendedCAServiceRequestException
356      * @throws CADoesntExistsException
357      * @see org.ejbca.util.query.Query
358      *
359      * @ejb.interface-method view-type="both"
360      * @ejb.transaction type="Supports"
361      *
362      */

363     public byte[] export(Admin admin, Query query, String JavaDoc viewlogprivileges, String JavaDoc capriviledges, ILogExporter logexporter) throws IllegalQueryException, CADoesntExistsException, ExtendedCAServiceRequestException, IllegalExtendedCAServiceRequestException, ExtendedCAServiceNotActiveException {
364         byte[] ret = null;
365         if (query != null) {
366             Collection JavaDoc logentries = query(query, viewlogprivileges, capriviledges);
367             if (log.isDebugEnabled()) {
368                 log.debug("Found "+logentries.size()+" entries when exporting");
369             }
370             logexporter.setEntries(logentries);
371             ret = logexporter.export();
372             String JavaDoc ca = logexporter.getSigningCA();
373             if (log.isDebugEnabled()) {
374                 log.debug("Signing CA is '"+ca+"'");
375             }
376             if ( (ret != null) && StringUtils.isNotEmpty(ca) ) {
377                 try {
378                     int caid = Integer.parseInt(ca);
379                     ISignSessionLocal sign = signsessionhome.create();
380                     CmsCAServiceRequest request = new CmsCAServiceRequest(ret, true);
381                     CmsCAServiceResponse resp = (CmsCAServiceResponse)sign.extendedService(admin, caid, request);
382                     ret = resp.getCmsDocument();
383                 } catch (CreateException JavaDoc e) {
384                     log.error("Can not create sign session", e);
385                 }
386             }
387         }
388         return ret;
389     }
390     
391     /**
392      * Method to execute a customized query on the log db data. The parameter query should be a legal Query object.
393      *
394      * @param query a number of statments compiled by query class to a SQL 'WHERE'-clause statment.
395      * @param viewlogprivileges is a sql query string returned by a LogAuthorization object.
396      * @return a collection of LogEntry. Maximum size of Collection is defined i LogConstants.MAXIMUM_QUERY_ROWCOUNT
397      * @throws IllegalQueryException when query parameters internal rules isn't fullfilled.
398      * @see org.ejbca.util.query.Query
399      *
400      * @ejb.interface-method view-type="both"
401      * @ejb.transaction type="Supports"
402      *
403      */

404     public Collection JavaDoc query(Query query, String JavaDoc viewlogprivileges, String JavaDoc capriviledges) throws IllegalQueryException {
405         debug(">query()");
406         if (capriviledges == null || capriviledges.length() == 0 || !query.isLegalQuery()) {
407             throw new IllegalQueryException();
408         }
409
410         Connection JavaDoc con = null;
411         PreparedStatement JavaDoc ps = null;
412         ResultSet JavaDoc rs = null;
413         try {
414             // Construct SQL query.
415
con = JDBCUtil.getDBConnection(JNDINames.DATASOURCE);
416             String JavaDoc sql = "select "+LOGENTRYDATA_COL+", "+LOGENTRYDATA_COL_COMMENT_OLD+" from "+LOGENTRYDATA_TABLE+" where ( "
417                     + query.getQueryString() + ") and (" + capriviledges + ")";
418             // Different column names is an unforturnalte workaround because of Orcale, you cannot have a column named 'comment' in Oracle.
419
// The workaround 'comment_' was spread in the wild in 2005, so we have to use it so far.
420
if (!JDBCUtil.columnExists(con, LOGENTRYDATA_TABLE, LOGENTRYDATA_COL_COMMENT_OLD)) {
421                 log.debug("Using oracle column name 'comment_' in LogEntryData.");
422                 sql = StringUtils.replace(sql, LOGENTRYDATA_COL_COMMENT_OLD, LOGENTRYDATA_COL_COMMENT_ORA);
423             }
424             if (StringUtils.isNotEmpty(viewlogprivileges)) {
425                 sql += " and (" + viewlogprivileges + ")";
426             }
427             if (log.isDebugEnabled()) {
428                 log.debug("Query: "+sql);
429             }
430             ps = con.prepareStatement(sql);
431             //ps.setFetchDirection(ResultSet.FETCH_REVERSE);
432
ps.setFetchSize(LogConstants.MAXIMUM_QUERY_ROWCOUNT + 1);
433             // Execute query.
434
rs = ps.executeQuery();
435             // Assemble result.
436
ArrayList JavaDoc returnval = new ArrayList JavaDoc();
437             while (rs.next() && returnval.size() <= LogConstants.MAXIMUM_QUERY_ROWCOUNT) {
438                 LogEntry data = new LogEntry(rs.getInt(1), rs.getInt(2), rs.getString(3), rs.getInt(4), rs.getInt(5), new Date JavaDoc(rs.getLong(6)), rs.getString(7),
439                         rs.getString(8), rs.getInt(9), rs.getString(10));
440                 if (logsigning) {
441                     TableProtectSessionLocal protect = protecthome.create();
442                     TableVerifyResult res = protect.verify(data);
443                     data.setVerifyResult(res.getResultConstant());
444                 }
445                 returnval.add(data);
446             }
447             return returnval;
448
449         } catch (Exception JavaDoc e) {
450             throw new EJBException JavaDoc(e);
451         } finally {
452             JDBCUtil.close(con, ps, rs);
453         }
454     } // query
455

456     /**
457      * Loads the log configuration from the database.
458      *
459      * @return the logconfiguration
460      *
461      * @ejb.interface-method view-type="both"
462      * @ejb.transaction type="Supports"
463      *
464      */

465     public LogConfiguration loadLogConfiguration(int caid) {
466         // Check if log configuration exists, else create one.
467
LogConfiguration logconfiguration = null;
468         LogConfigurationDataLocal logconfigdata = null;
469         try {
470             logconfigdata = logconfigurationhome.findByPrimaryKey(new Integer JavaDoc(caid));
471             logconfiguration = logconfigdata.loadLogConfiguration();
472         } catch (FinderException JavaDoc e) {
473             log.debug("Can't find log configuration during load (caid="+caid+"), trying to create new: ", e);
474             try {
475                 logconfiguration = new LogConfiguration();
476                 logconfigdata = logconfigurationhome.create(new Integer JavaDoc(caid), logconfiguration);
477             } catch (CreateException JavaDoc f) {
478                 String JavaDoc msg = intres.getLocalizedMessage("log.errorcreateconf", new Integer JavaDoc(caid));
479                 log.error(msg, f);
480                 throw new EJBException JavaDoc(f);
481             }
482         }
483
484         return logconfiguration;
485     } // loadLogConfiguration
486

487     /**
488      * Saves the log configuration to the database.
489      *
490      * @param logconfiguration the logconfiguration to save.
491      *
492      * @ejb.interface-method view-type="both"
493      * @ejb.transaction type="Required"
494      *
495      */

496     public void saveLogConfiguration(Admin admin, int caid, LogConfiguration logconfiguration) {
497         try {
498             try {
499                 (logconfigurationhome.findByPrimaryKey(new Integer JavaDoc(caid))).saveLogConfiguration(logconfiguration);
500                 log(admin, caid, LogEntry.MODULE_LOG, new Date JavaDoc(), null, null, LogEntry.EVENT_INFO_EDITLOGCONFIGURATION, "");
501             } catch (FinderException JavaDoc e) {
502                 String JavaDoc msg = intres.getLocalizedMessage("log.createconf", new Integer JavaDoc(caid));
503                 log.info(msg);
504                 logconfigurationhome.create(new Integer JavaDoc(caid), logconfiguration);
505                 log(admin, caid, LogEntry.MODULE_LOG, new Date JavaDoc(), null, null, LogEntry.EVENT_INFO_EDITLOGCONFIGURATION, "");
506             }
507         } catch (Exception JavaDoc e) {
508             log(admin, caid, LogEntry.MODULE_LOG, new Date JavaDoc(), null, null, LogEntry.EVENT_ERROR_EDITLOGCONFIGURATION, "");
509             throw new EJBException JavaDoc(e);
510         }
511     } // saveLogConfiguration
512

513
514     private Integer JavaDoc getAndIncrementRowCount() {
515         if (this.logconfigurationdata == null) {
516             try {
517                 logconfigurationdata = logconfigurationhome.findByPrimaryKey(new Integer JavaDoc(0));
518             } catch (FinderException JavaDoc e) {
519                 try {
520                     LogConfiguration logconfiguration = new LogConfiguration();
521                     this.logconfigurationdata = logconfigurationhome.create(new Integer JavaDoc(0), logconfiguration);
522                 } catch (CreateException JavaDoc f) {
523                     throw new EJBException JavaDoc(f);
524                 }
525             }
526         }
527
528         return this.logconfigurationdata.getAndIncrementRowCount();
529     }
530
531 } // LocalLogSessionBean
532
Popular Tags