bug #8366
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@66786 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
1f8674f41d
commit
d6da1c1879
|
@ -65,37 +65,44 @@ public class AuditInterceptor extends EmptyInterceptor {
|
||||||
|
|
||||||
private boolean getAuditModuleService() {
|
private boolean getAuditModuleService() {
|
||||||
|
|
||||||
if (!AuditManager.getINSTANCE().getCheckModuleAudit()) {
|
Session session = null;
|
||||||
return AuditManager.getINSTANCE().getCurrentService() != null ? true : false;
|
try {
|
||||||
}
|
if (!AuditManager.getINSTANCE().getCheckModuleAudit()) {
|
||||||
|
return AuditManager.getINSTANCE().getCurrentService() != null ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
AuditService auditService = null;
|
AuditService auditService = null;
|
||||||
|
|
||||||
SessionFactory sessionFactory = DBUtil.getInstance().getSessionFactory();
|
SessionFactory sessionFactory = DBUtil.getInstance().getSessionFactory();
|
||||||
Session session = sessionFactory.openSession();
|
session = sessionFactory.openSession();
|
||||||
|
|
||||||
Criteria criteriaFuncionSistema = session.createCriteria(FuncionSistema.class);
|
Criteria criteriaFuncionSistema = session.createCriteria(FuncionSistema.class);
|
||||||
criteriaFuncionSistema.add(Restrictions.eq("descruta", AuditManager.getINSTANCE().getCurrentActionService()));
|
criteriaFuncionSistema.add(Restrictions.eq("descruta", AuditManager.getINSTANCE().getCurrentActionService()));
|
||||||
FuncionSistema funcionSistema = (FuncionSistema) criteriaFuncionSistema.uniqueResult();
|
FuncionSistema funcionSistema = (FuncionSistema) criteriaFuncionSistema.uniqueResult();
|
||||||
|
|
||||||
|
if (funcionSistema == null) {
|
||||||
|
Log.info("Função sistema " + funcionSistema + " não encontrada na base de dados.");
|
||||||
|
AuditManager.getINSTANCE().setCurrentService(auditService);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Criteria criteriaService = session.createCriteria(AuditService.class);
|
||||||
|
criteriaService.add(Restrictions.eq("funcionSistema", funcionSistema));
|
||||||
|
auditService = (AuditService) criteriaService.uniqueResult();
|
||||||
|
|
||||||
|
if (auditService == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (funcionSistema == null) {
|
|
||||||
Log.info("Função sistema " + funcionSistema + " não encontrada na base de dados.");
|
|
||||||
AuditManager.getINSTANCE().setCurrentService(auditService);
|
AuditManager.getINSTANCE().setCurrentService(auditService);
|
||||||
return false;
|
AuditManager.getINSTANCE().setCheckModuleAudit(Boolean.FALSE);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
if (session != null)
|
||||||
|
session.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
Criteria criteriaService = session.createCriteria(AuditService.class);
|
|
||||||
criteriaService.add(Restrictions.eq("funcionSistema", funcionSistema));
|
|
||||||
auditService = (AuditService) criteriaService.uniqueResult();
|
|
||||||
|
|
||||||
if (auditService == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
AuditManager.getINSTANCE().setCurrentService(auditService);
|
|
||||||
AuditManager.getINSTANCE().setCheckModuleAudit(Boolean.FALSE);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void genAudit(Object entity, EnumAuditAction action) {
|
private void genAudit(Object entity, EnumAuditAction action) {
|
||||||
|
@ -103,6 +110,8 @@ public class AuditInterceptor extends EmptyInterceptor {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Session session = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/**
|
/**
|
||||||
* Ignorado caso a entidade for de auditoria e se não for encontrado o módulo no banco
|
* Ignorado caso a entidade for de auditoria e se não for encontrado o módulo no banco
|
||||||
|
@ -130,7 +139,7 @@ public class AuditInterceptor extends EmptyInterceptor {
|
||||||
audit.setUsuario(UsuarioLogado.getUsuarioLogado());
|
audit.setUsuario(UsuarioLogado.getUsuarioLogado());
|
||||||
|
|
||||||
SessionFactory sessionFactory = DBUtil.getInstance().getSessionFactory();
|
SessionFactory sessionFactory = DBUtil.getInstance().getSessionFactory();
|
||||||
Session session = sessionFactory.openSession();
|
session = sessionFactory.openSession();
|
||||||
|
|
||||||
session.persist(audit);
|
session.persist(audit);
|
||||||
session.flush();
|
session.flush();
|
||||||
|
@ -140,6 +149,9 @@ public class AuditInterceptor extends EmptyInterceptor {
|
||||||
|
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
log.error(exception.getStackTrace());
|
log.error(exception.getStackTrace());
|
||||||
|
} finally {
|
||||||
|
if (session != null)
|
||||||
|
session.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue