1 19 20 package org.jahia.admin.components; 21 22 import java.sql.Connection ; 23 import java.sql.SQLException ; 24 import java.sql.Statement ; 25 26 import org.jahia.exceptions.JahiaException; 27 import org.jahia.registries.ServicesRegistry; 28 29 public class DBTools { 30 31 47 protected static boolean insertAuditLogEntry (int entryID, 48 String timeStr, 49 String userNameStr, 50 String objectTypeStr, 51 String objectIDStr, 52 String parentObjIDStr, 53 String parentTypeStr, 54 String operationStr, 55 String contentStr) throws 56 JahiaException { 57 String MSG_INTERNAL_ERROR = new String ( 58 "Jahia Administration internal error"); 59 60 ServicesRegistry registry = ServicesRegistry.getInstance(); 62 if (registry == null) { 63 throw new JahiaException(MSG_INTERNAL_ERROR, 64 "JahiaAdministration could not get the Service Registry instance.", 65 JahiaException.REGISTRY_ERROR, 66 JahiaException.CRITICAL_SEVERITY); 67 } 68 69 Connection dbConn = null; 70 71 try { 72 dbConn = org.jahia.services.database.ConnectionDispenser. 73 getConnection(); 74 } catch (NullPointerException npe) { 75 } 77 78 if (dbConn == null) { 79 return false; 80 } 81 82 boolean result = true; 84 Statement statement = null; 85 86 try { 87 statement = dbConn.createStatement(); 88 89 String query = "INSERT INTO jahia_audit_log (id_jahia_audit_log, time_jahia_audit_log, username_jahia_audit_log, objecttype_jahia_audit_log, operation_jahia_audit_log, objectid_jahia_audit_log, parentid_jahia_audit_log, parenttype_jahia_audit_log, content_jahia_audit_log ) VALUES (" 90 + Integer.toString(entryID) 91 + ",'" + timeStr 92 + "','" + userNameStr 93 + "'," + objectTypeStr 94 + ",'" + operationStr 95 + "'," + objectIDStr 96 + "," + parentObjIDStr 97 + "," + parentTypeStr 98 + ",'" + contentStr + "')"; 99 statement.executeUpdate(query); 100 101 } catch (SQLException sqlEx) { 102 result = false; 104 } finally { 105 try { 107 if (statement != null) { 108 statement.close(); 109 } 110 } catch (SQLException se) { 111 } 114 } 115 return result; 116 } 117 118 } | Popular Tags |