use of org.olat.resource.accesscontrol.model.AbstractAccessMethod in project openolat by klemens.
the class ACMethodDAO method activateTokenMethod.
/**
* Activate the token method if not already configured.
*/
protected void activateTokenMethod(boolean enable) {
StringBuilder sb = new StringBuilder();
sb.append("select method from actokenmethod method");
List<AccessMethod> methods = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), AccessMethod.class).getResultList();
if (methods.isEmpty() && enable) {
TokenAccessMethod method = new TokenAccessMethod();
method.setCreationDate(new Date());
method.setLastModified(method.getCreationDate());
dbInstance.getCurrentEntityManager().persist(method);
} else {
for (AccessMethod method : methods) {
if (method.isEnabled() != enable) {
((AbstractAccessMethod) method).setEnabled(enable);
((AbstractAccessMethod) method).setLastModified(new Date());
dbInstance.getCurrentEntityManager().merge(method);
}
}
}
}
Aggregations