コード例 #1
0
  /**
   * Commit the database level changes. Declared in AbstractDAO class.
   *
   * @throws DAOException
   */
  public void commit() throws DAOException {
    try {
      auditManager.insert(this);

      if (transaction != null) transaction.commit();
    } catch (HibernateException dbex) {
      Logger.out.error(dbex.getMessage(), dbex);
      throw handleError("Error in commit: ", dbex);
    }
  }
コード例 #2
0
 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);
   }
 }
コード例 #3
0
  /**
   * This method will be used to establish the session with the database. Declared in AbstractDAO
   * class.
   *
   * @throws DAOException
   */
  public void openSession(SessionDataBean sessionDataBean) throws DAOException {
    // Logger.out.info("Session opened:------------------------");
    try {
      session = DBUtil.currentSession();

      // Logger.out.info("Transaction begin:---------------------");
      transaction = session.beginTransaction();

      auditManager = new AuditManager();

      if (sessionDataBean != null) {
        auditManager.setUserId(sessionDataBean.getUserId());
        auditManager.setIpAddress(sessionDataBean.getIpAddress());
      } else {
        auditManager.setUserId(null);
      }
    } catch (HibernateException dbex) {
      Logger.out.error(dbex.getMessage(), dbex);
      throw handleError(Constants.GENERIC_DATABASE_ERROR, dbex);
    }
  }
コード例 #4
0
  /**
   * 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);
    }
  }
コード例 #5
0
 public void addAuditEventLogs(Collection auditEventDetailsCollection) {
   auditManager.addAuditEventLogs(auditEventDetailsCollection);
 }