public void audit(Object obj, Object oldObj, SessionDataBean sessionDataBean, boolean isAuditable) throws DAOException { try { if (obj instanceof Auditable && isAuditable) { // Logger.out.debug("In update audit..................................."); auditManager.compare((Auditable) obj, (Auditable) oldObj, "UPDATE"); } } catch (AuditException hibExp) { throw handleError("", hibExp); } }
/** * Saves the persistent object in the database. * * @param obj The object to be saved. * @param session The session in which the object is saved. * @throws DAOException * @throws HibernateException Exception thrown during hibernate operations. */ public void insert( Object obj, SessionDataBean sessionDataBean, boolean isAuditable, boolean isSecureInsert) throws DAOException, UserNotAuthorizedException { // Logger.out.info("inser call---------------------"); boolean isAuthorized = true; try { if (isSecureInsert) { if (null != sessionDataBean) { String userName = sessionDataBean.getUserName(); if (userName != null) { isAuthorized = SecurityManager.getInstance(this.getClass()) .isAuthorized(userName, obj.getClass().getName(), Permissions.CREATE); } else { isAuthorized = false; } } else { isAuthorized = false; } } // Logger.out.debug(" User's Authorization to insert "+obj.getClass()+" , "+isAuthorized); if (isAuthorized) { session.save(obj); if (obj instanceof Auditable && isAuditable) auditManager.compare((Auditable) obj, null, "INSERT"); isUpdated = true; } else { throw new UserNotAuthorizedException("Not Authorized to insert"); } } catch (HibernateException hibExp) { throw handleError("", hibExp); } catch (AuditException hibExp) { throw handleError("", hibExp); } catch (SMException smex) { throw handleError("", smex); } }