use of org.springframework.data.envers.repository.support.EnversRevisionRepositoryFactoryBean in project irida by phac-nml.
the class ForbidJpqlUpdateDeletePostProcessor method postProcessAfterInitialization.
/**
* {@inheritDoc}
*/
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (beanName.endsWith("Repository") && bean instanceof EnversRevisionRepositoryFactoryBean) {
logger.trace("Found a repository class... [" + beanName + "]");
final EnversRevisionRepositoryFactoryBean factory = (EnversRevisionRepositoryFactoryBean) bean;
try {
final Iterable<Method> queryMethods = factory.getRepositoryInformation().getQueryMethods();
for (final Method queryMethod : queryMethods) {
if (queryMethod.isAnnotationPresent(Query.class) || queryMethod.isAnnotationPresent(Modifying.class)) {
final Query q = queryMethod.getAnnotation(Query.class);
final String queryValue = q.value().toLowerCase();
if (queryValue.contains("update") || queryValue.contains("delete")) {
throw new BeanCreationNotAllowedException(beanName, "Update and Delete are not allowed in JPQL because Envers doesn't audit those queries. Remove the update or delete from the method [" + queryMethod.getName() + "]");
}
}
}
} finally {
}
}
return bean;
}
Aggregations