KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > services > fields > JahiaFieldDefinitionsDB


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
// JahiaFieldDefinitionsDB
15
// EV 05.01.2001
16
//
17
// db_load_field_definition( defID ) -> JahieFieldDefinition
18
// db_create_field_definition( theFieldDefinition )
19
// db_update_field_definition( theFieldDefinition )
20
// db_delete_field_definition( defID )
21
//
22

23
24 package org.jahia.services.fields;
25
26 import java.io.File JavaDoc;
27 import java.io.IOException JavaDoc;
28 import java.sql.Connection JavaDoc;
29 import java.sql.PreparedStatement JavaDoc;
30 import java.sql.ResultSet JavaDoc;
31 import java.sql.SQLException JavaDoc;
32 import java.sql.Statement JavaDoc;
33 import java.util.Enumeration JavaDoc;
34 import java.util.Hashtable JavaDoc;
35
36 import org.apache.log4j.Logger;
37 import org.jahia.data.JahiaDBDOMObject;
38 import org.jahia.data.JahiaDOMObject;
39 import org.jahia.data.fields.JahiaFieldDefinition;
40 import org.jahia.data.fields.JahiaFieldSubDefinition;
41 import org.jahia.exceptions.JahiaException;
42 import org.jahia.registries.ServicesRegistry;
43 import org.jahia.services.database.ConnectionDispenser;
44 import org.jahia.utils.FileUtils;
45 import org.jahia.utils.JahiaTools;
46
47
48 public class JahiaFieldDefinitionsDB {
49
50     public static final String JavaDoc defaultValueFlatFileMarker = "<defvalue_in_flat_file>";
51
52     private static Logger logger = Logger.getLogger (JahiaFieldDefinitionsDB.class);
53
54     /**
55      * constructor
56      */

57     public JahiaFieldDefinitionsDB () {
58     } // end constructor
59

60
61     /**
62      * loads a field definition by its id
63      *
64      * @param theDefID the field definition ID
65      *
66      * @return a JahiaFieldDefinition object
67      *
68      * @throws throws a critical JahiaException if SQL error
69      * @throws throws a warning JahiaException if cannot free resources
70      * @see org.jahia.data.fields.JahiaFieldDefinition
71      */

72     public JahiaFieldDefinition db_load_field_definition (int theDefID)
73             throws JahiaException {
74         Connection JavaDoc dbConn = null;
75         PreparedStatement JavaDoc stmt1 = null;
76         PreparedStatement JavaDoc stmt2 = null;
77         ResultSet JavaDoc rs = null;
78         ResultSet JavaDoc rs2 = null;
79         JahiaFieldDefinition theFieldDef = null;
80         try {
81             // creates connexion
82
dbConn = ConnectionDispenser.getConnection ();
83
84             // prepares sqlQuery
85
String JavaDoc sqlQuery = "SELECT * FROM jahia_fields_def ";
86             sqlQuery += "WHERE id_jahia_fields_def = ?";
87             stmt1 = dbConn.prepareStatement (sqlQuery);
88             stmt1.setInt(1, theDefID);
89             rs = stmt1.executeQuery ();
90             if (rs.next ()) {
91                 int ID = rs.getInt ("id_jahia_fields_def");
92                 int jahiaID = rs.getInt ("jahiaid_jahia_fields_def");
93                 String JavaDoc name = rs.getString ("name_jahia_fields_def");
94
95                 sqlQuery = "SELECT * FROM jahia_fields_def_prop ";
96                 sqlQuery += "WHERE flddefid_jahia_fields_def_prop=?";
97                 stmt2 = dbConn.prepareStatement (sqlQuery);
98                 stmt2.setInt(1, ID);
99                 rs2 = stmt2.executeQuery ();
100
101                 Hashtable JavaDoc subDefs = new Hashtable JavaDoc ();
102
103                 while (rs2.next ()) {
104                     int subDefID = rs2.getInt ("id_jahia_fields_def_prop");
105                     int templateID = rs2.getInt ("pdefid_jahia_fields_def_prop");
106                     String JavaDoc title = rs2.getString ("title_jahia_fields_def_prop");
107                     int type = rs2.getInt ("type_jahia_fields_def_prop");
108                     String JavaDoc defaultValue = rs2.getString ("default_jahia_fields_def_prop");
109                     if (defaultValue.equals ("<empty>")) {
110                         defaultValue = "";
111                     } else {
112                         String JavaDoc filePath = ServicesRegistry.getInstance ()
113                                 .getJahiaFieldService ()
114                                 .composeFieldDefDefaultValueFilePath (jahiaID, name);
115                         File JavaDoc f = new File JavaDoc (filePath);
116                         if (f.exists ()) {
117                             defaultValue =
118                                     FileUtils.getInstance ().readFile (f.getAbsolutePath ());
119                         }
120                     }
121                     subDefs.put (new Integer JavaDoc (templateID),
122                             new JahiaFieldSubDefinition (subDefID, ID, templateID, title, type,
123                                     defaultValue));
124                 }
125
126                 theFieldDef = new JahiaFieldDefinition (ID, jahiaID, name, subDefs);
127             }
128         } catch (SQLException JavaDoc se) {
129             String JavaDoc errorMsg = "Error in db_load_field_definition : " + se.getMessage ();
130             logger.error (errorMsg + " -> BAILING OUT");
131             throw new JahiaException ("Cannot load fields from the database",
132                     errorMsg, JahiaException.DATABASE_ERROR, JahiaException.CRITICAL_SEVERITY);
133         } finally {
134             try {
135
136                 if (stmt1 != null) stmt1.close ();
137                 if (stmt2 != null) stmt2.close ();
138             } catch (SQLException JavaDoc ex) {
139                 new JahiaException ("Cannot free resources",
140                         "db_load_field_definition : cannot free resources",
141                         JahiaException.DATABASE_ERROR, JahiaException.WARNING_SEVERITY);
142             }
143         }
144         if (theFieldDef != null) {
145             theFieldDef.setProperties (FieldDefinitionPropertiesPersistence
146                     .getInstance ()
147                     .loadFieldDefinitionProperties (theFieldDef.getID ()));
148         }
149         return theFieldDef;
150
151     } // end db_load_field_definition
152

153
154     /**
155      * loads a field definition by its name and its site id
156      *
157      * @param siteID the site id
158      * @param name the field name
159      *
160      * @return a JahiaFieldDefinition object
161      *
162      * @throws throws a critical JahiaException if SQL error
163      * @throws throws a warning JahiaException if cannot free resources
164      * @see org.jahia.data.fields.JahiaFieldDefinition
165      */

166     public JahiaFieldDefinition db_load_field_definition (int siteID, String JavaDoc name)
167             throws JahiaException {
168         Connection JavaDoc dbConn = null;
169         PreparedStatement JavaDoc stmt = null;
170         PreparedStatement JavaDoc stmt2 = null;
171         ResultSet JavaDoc rs = null;
172         ResultSet JavaDoc rs2 = null;
173         JahiaFieldDefinition theFieldDef = null;
174         try {
175             // creates connexion
176
dbConn = ConnectionDispenser.getConnection ();
177
178             stmt = dbConn.prepareStatement("SELECT * FROM jahia_fields_def WHERE jahiaid_jahia_fields_def = ? and name_jahia_fields_def=?");
179             stmt.setInt(1, siteID);
180             stmt.setString(2, name);
181             rs = stmt.executeQuery ();
182             if (rs.next ()) {
183                 int ID = rs.getInt ("id_jahia_fields_def");
184                 int jahiaID = rs.getInt ("jahiaid_jahia_fields_def");
185                 name = rs.getString ("name_jahia_fields_def");
186
187                 stmt2 = dbConn.prepareStatement("SELECT * FROM jahia_fields_def_prop WHERE flddefid_jahia_fields_def_prop=?");
188                 stmt2.setInt(1, ID);
189
190                 rs2 = stmt2.executeQuery ();
191
192                 Hashtable JavaDoc subDefs = new Hashtable JavaDoc ();
193
194                 while (rs2.next ()) {
195                     int subDefID = rs2.getInt ("id_jahia_fields_def_prop");
196                     int templateID = rs2.getInt ("pdefid_jahia_fields_def_prop");
197                     String JavaDoc title = rs2.getString ("title_jahia_fields_def_prop");
198                     int type = rs2.getInt ("type_jahia_fields_def_prop");
199                     String JavaDoc defaultValue = rs2.getString ("default_jahia_fields_def_prop");
200                     if (defaultValue.equals ("<empty>")) {
201                         defaultValue = "";
202                     } else if (defaultValue.equals (
203                             JahiaFieldDefinitionsDB.defaultValueFlatFileMarker)) {
204                         String JavaDoc filePath = ServicesRegistry.getInstance ()
205                                 .getJahiaFieldService ()
206                                 .composeFieldDefDefaultValueFilePath (siteID, name);
207                         File JavaDoc f = new File JavaDoc (filePath);
208                         if (f.exists ()) {
209                             defaultValue =
210                                     FileUtils.getInstance ().readFile (f.getAbsolutePath ());
211                         }
212                     }
213                     subDefs.put (new Integer JavaDoc (templateID),
214                             new JahiaFieldSubDefinition (subDefID, ID, templateID, title, type,
215                                     defaultValue));
216                 }
217
218                 theFieldDef = new JahiaFieldDefinition (ID, jahiaID, name, subDefs);
219             }
220         } catch (SQLException JavaDoc se) {
221             String JavaDoc errorMsg = "Error in db_load_field_definition : " + se.getMessage ();
222             logger.error (errorMsg + " -> BAILING OUT");
223             throw new JahiaException ("Cannot load fields from the database",
224                     errorMsg, JahiaException.DATABASE_ERROR, JahiaException.CRITICAL_SEVERITY);
225         } finally {
226             closeStatement(stmt);
227             closeStatement(stmt2);
228         }
229         if (theFieldDef != null) {
230             theFieldDef.setProperties (FieldDefinitionPropertiesPersistence
231                     .getInstance ()
232                     .loadFieldDefinitionProperties (theFieldDef.getID ()));
233         }
234         return theFieldDef;
235
236     } // end db_load_field_definition
237

238
239     /**
240      * creates a field definition, and assignes it a new ID
241      *
242      * @param theFieldDef the Field Definition
243      *
244      * @throws throws a critical JahiaException if SQL error
245      * @throws throws a warning JahiaException if cannot free resources
246      * @see org.jahia.data.fields.JahiaFieldDefinition
247      */

248     public void db_create_field_definition (JahiaFieldDefinition theFieldDef)
249             throws JahiaException {
250         Connection JavaDoc dbConn = null;
251         PreparedStatement JavaDoc stmt = null;
252         try {
253             // gets the field id
254
ServicesRegistry sr = ServicesRegistry.getInstance ();
255             int theFieldDefID = sr.getJahiaIncrementorsDBService ().autoIncrement (
256                     "jahia_fields_def");
257
258             theFieldDef.setID (theFieldDefID);
259             String JavaDoc sqlQuery =
260                 "INSERT INTO jahia_fields_def (id_jahia_fields_def,jahiaid_jahia_fields_def,name_jahia_fields_def) VALUES(?,?,?)";
261             // opens connection
262
dbConn = ConnectionDispenser.getConnection ();
263             stmt = dbConn.prepareStatement (sqlQuery);
264             stmt.setInt(1, theFieldDef.getID ());
265             stmt.setInt(2, theFieldDef.getJahiaID ());
266             stmt.setString(3, theFieldDef.getName ());
267
268             // saves definition base
269
stmt.executeUpdate ();
270
271             // enters values with update_jahia_field
272
db_update_field_defprop (theFieldDef);
273         }
274                 // catches error if cannot execute insert query
275
catch (SQLException JavaDoc se) {
276             String JavaDoc errorMsg = "Error in create_jahia_field_definition : " + se.getMessage ();
277             logger.error (errorMsg + " -> BAILING OUT");
278             throw new JahiaException ("Cannot insert new fields definitions in the database",
279                     errorMsg, JahiaException.DATABASE_ERROR, JahiaException.CRITICAL_SEVERITY);
280
281         } finally {
282             closeStatement(stmt);
283         }
284     } // end db_create_field_definition
285

286     public void db_create_field_defprop(JahiaFieldDefinition theFieldDef) throws JahiaException {
287         Connection JavaDoc dbConn = null;
288         PreparedStatement JavaDoc stmt = null;
289         String JavaDoc sqlQuery = "";
290         try {
291
292             // creates the connection
293
dbConn = ConnectionDispenser.getConnection();
294
295             sqlQuery = "INSERT INTO jahia_fields_def_prop (id_jahia_fields_def_prop,flddefid_jahia_fields_def_prop,pdefid_jahia_fields_def_prop,";
296             sqlQuery += "title_jahia_fields_def_prop,type_jahia_fields_def_prop,default_jahia_fields_def_prop) VALUES(?,?,?,?,?,?)";
297             stmt = dbConn.prepareStatement(sqlQuery);
298
299             // saves all sub definitions
300
Hashtable JavaDoc subDefs = theFieldDef.getSubDefs();
301             Enumeration JavaDoc subKeys = subDefs.keys();
302             while (subKeys.hasMoreElements()) {
303                 int pageDefID = ((Integer JavaDoc) subKeys.nextElement()).intValue();
304
305                 JahiaFieldSubDefinition theSubDef = (JahiaFieldSubDefinition) subDefs.get(new Integer JavaDoc(pageDefID));
306                 // sets the subdef id
307
if (theSubDef.getID() == 0) {
308                     int theSubDefID = ServicesRegistry.getInstance().getJahiaIncrementorsDBService().autoIncrement(
309                             "jahia_fields_def_prop");
310                     theSubDef.setID(theSubDefID);
311                     theSubDef.setFieldDefID(theFieldDef.getID());
312                 }
313
314                 String JavaDoc defaultVal = theFieldDef.getDefaultValue(pageDefID);
315                 if (defaultVal == null || "".equals(defaultVal)) {
316                     defaultVal = "<empty>"; // FIXME : Small text size should
317
// not be hardcoded
318
} else if (defaultVal.length() > 250) {
319                     String JavaDoc filePath = ServicesRegistry.getInstance().getJahiaFieldService()
320                             .composeFieldDefDefaultValueFilePath(theFieldDef.getJahiaID(), theFieldDef.getName());
321                     File JavaDoc f = new File JavaDoc(filePath);
322                     f.createNewFile();
323                     FileUtils.getInstance().writeFile(f.getAbsolutePath(), theFieldDef.getDefaultValue(pageDefID));
324                     defaultVal = JahiaFieldDefinitionsDB.defaultValueFlatFileMarker;
325                 }
326
327                 if (theSubDef.getTitle().length() > 0 && theSubDef.getType() != -1) {
328                     // composes the query
329
stmt.setInt(1, theSubDef.getID());
330                     stmt.setInt(2, theFieldDef.getID());
331                     stmt.setInt(3, pageDefID);
332                     stmt.setString(4, JahiaTools.quote(theSubDef.getTitle()));
333                     stmt.setInt(5, theSubDef.getType());
334                     stmt.setString(6, JahiaTools.quote(defaultVal));
335
336                     stmt.executeUpdate();
337                 }
338             }
339
340         }
341         // catches error if cannot execute update query
342
catch (IOException JavaDoc ioe) {
343             String JavaDoc errorMsg = "Error in db_update_field_definition : " + ioe.getMessage();
344             logger.error(errorMsg + " -> BAILING OUT");
345             throw new JahiaException("Cannot update fields definitions in the database", errorMsg,
346                     JahiaException.DATABASE_ERROR, JahiaException.CRITICAL_SEVERITY);
347         } catch (SQLException JavaDoc se) {
348             String JavaDoc errorMsg = "Error in db_update_field_definition : " + se.getMessage();
349             logger.error(errorMsg + " -> BAILING OUT");
350             throw new JahiaException("Cannot update fields definitions in the database", errorMsg,
351                     JahiaException.DATABASE_ERROR, JahiaException.CRITICAL_SEVERITY);
352         } finally {
353             closeStatement(stmt);
354         }
355     } // end db_update_field_definition
356

357     /**
358      * updates a field definition
359      *
360      * @param theFieldDef the Field Definition
361      *
362      * @throws throws a critical JahiaException if SQL error
363      * @throws throws a warning JahiaException if cannot free resources
364      * @see org.jahia.data.fields.JahiaFieldDefinition
365      */

366     public void db_update_field_defprop (JahiaFieldDefinition theFieldDef)
367             throws JahiaException {
368         Connection JavaDoc dbConn = null;
369         PreparedStatement JavaDoc stmt = null;
370         String JavaDoc sqlQuery = "";
371         try {
372
373             // creates the connexion
374
dbConn = ConnectionDispenser.getConnection ();
375             
376             // deletes all precedent sub definitions
377
sqlQuery = "DELETE FROM jahia_fields_def_prop WHERE flddefid_jahia_fields_def_prop=?";
378             stmt = dbConn.prepareStatement (sqlQuery);
379             stmt.setInt(1, theFieldDef.getID());
380
381             stmt.executeUpdate ();
382
383             db_create_field_defprop(theFieldDef);
384
385         } catch (SQLException JavaDoc se) {
386             String JavaDoc errorMsg = "Error in db_update_field_definition : " + se.getMessage ();
387             logger.error (errorMsg + " -> BAILING OUT");
388             throw new JahiaException ("Cannot update fields definitions in the database",
389                     errorMsg, JahiaException.DATABASE_ERROR, JahiaException.CRITICAL_SEVERITY);
390         } finally {
391             closeStatement(stmt);
392         }
393         
394         if (theFieldDef != null) {
395             FieldDefinitionPropertiesPersistence.getInstance ()
396                     .saveFieldDefinitionProperties (theFieldDef.getID (),
397                             theFieldDef.getProperties ());
398         }
399
400     } // end db_update_field_definition
401

402
403     /**
404      * Deletes a field Definition
405      * Warning: a same field def can be shared by different page definition
406      * within a same site !!!!
407      *
408      * @param fieldDefID the field definition id
409      *
410      * @throws throws a critical JahiaException if SQL error
411      * @throws throws a warning JahiaException if cannot free resources
412      * @see org.jahia.data.fields.JahiaFieldDefinition
413      */

414     public void db_delete_field_definition (int fieldDefID)
415             throws JahiaException {
416         Connection JavaDoc dbConn = null;
417         Statement JavaDoc stmt = null;
418         try {
419
420             // composes the query
421
String JavaDoc sqlQuery = "DELETE FROM " + jahia_fields_def +
422                     " WHERE " + FIELD_FIELD_ID + "=" + fieldDefID;
423
424             // executes the query
425
dbConn = ConnectionDispenser.getConnection ();
426             stmt = dbConn.createStatement ();
427             stmt.executeUpdate (sqlQuery);
428
429         }
430                 // catches error if cannot execute update query
431
catch (SQLException JavaDoc se) {
432             String JavaDoc errorMsg = "Error in db_delete_field_definition : " + se.getMessage ();
433             logger.error (errorMsg + " -> BAILING OUT");
434             throw new JahiaException ("Cannot delete fields definitions in the database",
435                     errorMsg, JahiaException.DATABASE_ERROR, JahiaException.CRITICAL_SEVERITY);
436         } finally {
437             closeStatement(stmt);
438         }
439         FieldDefinitionPropertiesPersistence.getInstance ()
440                 .deleteFieldDefinitionProperties (fieldDefID);
441
442     } // end db_delete_field_definition
443

444
445     /**
446      * Deletes all field sub def of a page definition
447      *
448      * @param pageDefID the page definition id
449      *
450      * @throws throws a critical JahiaException if SQL error
451      * @throws throws a warning JahiaException if cannot free resources
452      */

453     public void db_delete_field_sub_definition (int pageDefID)
454             throws JahiaException {
455         Connection JavaDoc dbConn = null;
456         Statement JavaDoc stmt = null;
457         try {
458
459             // composes the query
460
String JavaDoc sqlQuery = "DELETE FROM jahia_fields_def_prop " +
461                     " WHERE pdefid_jahia_fields_def_prop=" + pageDefID;
462
463             // executes the query
464
dbConn = ConnectionDispenser.getConnection ();
465             stmt = dbConn.createStatement ();
466             stmt.executeUpdate (sqlQuery);
467
468         }
469                 // catches error if cannot execute update query
470
catch (SQLException JavaDoc se) {
471             String JavaDoc errorMsg = "Error in db_delete_field_sub_definition : " + se.getMessage ();
472             logger.error (errorMsg + " -> BAILING OUT");
473             throw new JahiaException ("Cannot delete fields sub definitions in the database",
474                     errorMsg, JahiaException.DATABASE_ERROR, JahiaException.CRITICAL_SEVERITY);
475         } finally {
476             closeStatement(stmt);
477         }
478
479     } // end db_delete_field_sub_definition
480

481
482     //--------------------------------------------------------------------------
483
/**
484      * return a DOM document of all field def of a site
485      *
486      * @param int the site id
487      *
488      * @return JahiaDOMObject a DOM representation of this object
489      *
490      * @author NK
491      */

492     public JahiaDOMObject getFieldDefsAsDOM (int siteID) throws JahiaException {
493
494         Connection JavaDoc dbConn = null;
495         Statement JavaDoc statement = null;
496
497         JahiaDBDOMObject dom = null;
498
499         try {
500             String JavaDoc sqlQuery = "SELECT * FROM jahia_fields_def where jahiaid_jahia_fields_def=" + siteID;
501
502             dbConn = ConnectionDispenser.getConnection ();
503             statement = dbConn.createStatement ();
504             if (statement != null) {
505                 ResultSet JavaDoc rs = statement.executeQuery (sqlQuery);
506                 if (rs != null) {
507                     dom = new JahiaDBDOMObject ();
508                     dom.addTable ("jahia_fields_def", rs);
509                     return dom;
510                 }
511             }
512         } catch (SQLException JavaDoc se) {
513             String JavaDoc errorMsg = "Error in getFieldDefsAsDOM(int siteID) : " + se.getMessage ();
514             logger.error (errorMsg + " -> BAILING OUT");
515             throw new JahiaException ("Cannot load field def from the database",
516                     errorMsg, JahiaException.DATABASE_ERROR,
517                     JahiaException.CRITICAL_SEVERITY);
518         } finally {
519
520             closeStatement (statement);
521         }
522
523         return dom;
524     }
525
526     //--------------------------------------------------------------------------
527
/**
528      * return a DOM document of all field def props of a site
529      *
530      * @param int the site id
531      *
532      * @return JahiaDOMObject a DOM representation of this object
533      *
534      * @author NK
535      */

536     public JahiaDOMObject getFieldDefPropsAsDOM (int siteID)
537             throws JahiaException {
538
539         Connection JavaDoc dbConn = null;
540         Statement JavaDoc statement = null;
541
542         JahiaDBDOMObject dom = null;
543
544         try {
545
546             String JavaDoc sqlQuery = "SELECT DISTINCT jahia_fields_def_prop.id_jahia_fields_def_prop,"
547                     + "jahia_fields_def_prop.flddefid_jahia_fields_def_prop,jahia_fields_def_prop.pdefid_jahia_fields_def_prop,"
548                     + "jahia_fields_def_prop.title_jahia_fields_def_prop,jahia_fields_def_prop.type_jahia_fields_def_prop,"
549                     + "jahia_fields_def_prop.default_jahia_fields_def_prop"
550                     + " FROM jahia_fields_def_prop,jahia_fields_def"
551                     + " where jahia_fields_def_prop.flddefid_jahia_fields_def_prop="
552                     + " jahia_fields_def.id_jahia_fields_def AND jahia_fields_def.jahiaid_jahia_fields_def=" + siteID;
553
554             dbConn = ConnectionDispenser.getConnection ();
555             statement = dbConn.createStatement ();
556             if (statement != null) {
557                 ResultSet JavaDoc rs = statement.executeQuery (sqlQuery);
558                 if (rs != null) {
559                     dom = new JahiaDBDOMObject ();
560                     dom.addTable ("jahia_fields_def_prop", rs);
561                     return dom;
562                 }
563             }
564         } catch (SQLException JavaDoc se) {
565             String JavaDoc errorMsg = "Error in getFieldDefPropsAsDOM(int siteID) : " + se.getMessage ();
566             logger.error (errorMsg + " -> B AILING OUT");
567             throw new JahiaException ("Cannot load field def props from the database",
568                     errorMsg, JahiaException.DATABASE_ERROR,
569                     JahiaException.CRITICAL_SEVERITY);
570         } finally {
571
572             closeStatement (statement);
573         }
574
575         return dom;
576     }
577
578
579     //-------------------------------------------------------------------------
580
private void closeStatement (Statement JavaDoc statement) {
581         // Close the opened statement
582
try {
583             if (statement != null) {
584                 statement.close ();
585             }
586         } catch (SQLException JavaDoc sqlEx) {
587             logger.error ("Cannot close a statement", sqlEx);
588         }
589     }
590
591
592
593     ///////////////////////////////////////////////////////////////////////////
594
// PRIVATE DEFINITIONS
595
///////////////////////////////////////////////////////////////////////////
596

597     private static final String JavaDoc jahia_fields_def = "jahia_fields_def";
598     private static final String JavaDoc FIELD_FIELD_ID = "id_" + jahia_fields_def;
599
600 } // end FieldDefinitionsDBManager
601

602
Popular Tags