Commit d539e837 authored by Misagh Moayyed's avatar Misagh Moayyed
Browse files

remove Transactional in favor of AOP

parent 58552eac
......@@ -500,7 +500,7 @@ public final class CentralAuthenticationServiceImpl implements CentralAuthentica
throws AuthenticationException, TicketException {
final Set<Credential> sanitizedCredentials = sanitizeCredentials(credentials);
if (sanitizedCredentials.size() > 0) {
if (!sanitizedCredentials.isEmpty()) {
final Authentication authentication = this.authenticationManager.authenticate(credentials);
final TicketGrantingTicket ticketGrantingTicket = new TicketGrantingTicketImpl(
......
......@@ -69,18 +69,12 @@ public class SessionMonitor implements Monitor<SessionStatus> {
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return SessionMonitor.class.getSimpleName();
}
/**
* {@inheritDoc}
*/
@Override
public SessionStatus observe() {
try {
......
......@@ -62,14 +62,13 @@ public final class DefaultServicesManagerImpl implements ReloadableServicesManag
}
/**
* @deprecated As of 4.1. Use {@link #DefaultServicesManagerImpl(ServiceRegistryDao)}
* instead. The <code>defaultAttributes</code> parameter is no longer used. Attributes are configured
* per service definition in the services registry. See {@link RegisteredService#getAttributeReleasePolicy()}
* for more details.
* Constructs an instance of the {@link DefaultServicesManagerImpl} where the default RegisteredService
* can include a set of default attributes to use if no services are defined in the registry.
*
* @deprecated
* <p>As of 4.1. Use {@link #DefaultServicesManagerImpl(ServiceRegistryDao)}
* instead. The <code>defaultAttributes</code> parameter is no longer used. Attributes are configured
* per service definition in the services registry. See {@link RegisteredService#getAttributeReleasePolicy()}
* for more details.</p>
*
* @param serviceRegistryDao the Service Registry Dao.
* @param defaultAttributes the list of default attributes to use.
......@@ -81,7 +80,6 @@ public final class DefaultServicesManagerImpl implements ReloadableServicesManag
LOGGER.warn("This constructor is deprecated and will be removed in future CAS versions");
}
@Transactional(readOnly = false)
@Audit(action = "DELETE_SERVICE", actionResolverName = "DELETE_SERVICE_ACTION_RESOLVER",
resourceResolverName = "DELETE_SERVICE_RESOURCE_RESOLVER")
@Override
......@@ -97,9 +95,7 @@ public final class DefaultServicesManagerImpl implements ReloadableServicesManag
return r;
}
/**
* {@inheritDoc}
*/
@Override
public RegisteredService findServiceBy(final Service service) {
final Collection<RegisteredService> c = convertToTreeSet();
......@@ -130,9 +126,10 @@ public final class DefaultServicesManagerImpl implements ReloadableServicesManag
* @return the tree set
*/
protected TreeSet<RegisteredService> convertToTreeSet() {
return new TreeSet<RegisteredService>(this.services.values());
return new TreeSet<>(this.services.values());
}
@Override
public Collection<RegisteredService> getAllServices() {
return Collections.unmodifiableCollection(convertToTreeSet());
}
......@@ -142,7 +139,6 @@ public final class DefaultServicesManagerImpl implements ReloadableServicesManag
return findServiceBy(service) != null;
}
@Transactional(readOnly = false)
@Audit(action = "SAVE_SERVICE", actionResolverName = "SAVE_SERVICE_ACTION_RESOLVER",
resourceResolverName = "SAVE_SERVICE_RESOURCE_RESOLVER")
@Override
......
......@@ -26,8 +26,6 @@ import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostConstruct;
import javax.validation.constraints.NotNull;
import java.util.List;
......@@ -77,7 +75,6 @@ public final class MongoServiceRegistryDao implements ServiceRegistryDao {
}
@Override
@Transactional(readOnly = false)
public boolean delete(final RegisteredService svc) {
if (this.findServiceById(svc.getId()) != null) {
this.mongoTemplate.remove(svc, this.collectionName);
......@@ -88,20 +85,17 @@ public final class MongoServiceRegistryDao implements ServiceRegistryDao {
}
@Override
@Transactional(readOnly = true)
public RegisteredService findServiceById(final long svcId) {
return this.mongoTemplate.findOne(new Query(Criteria.where("id").is(svcId)),
RegisteredService.class, this.collectionName);
}
@Override
@Transactional(readOnly = true)
public List<RegisteredService> load() {
return this.mongoTemplate.findAll(RegisteredService.class, this.collectionName);
}
@Override
@Transactional(readOnly = false)
public RegisteredService save(final RegisteredService svc) {
if (svc.getId() == AbstractRegisteredService.INITIAL_IDENTIFIER_VALUE) {
((AbstractRegisteredService) svc).setId(svc.hashCode());
......
......@@ -18,8 +18,6 @@
*/
package org.jasig.cas.services;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.validation.constraints.NotNull;
......@@ -37,7 +35,6 @@ public final class JpaServiceRegistryDaoImpl implements ServiceRegistryDao {
@PersistenceContext
private EntityManager entityManager;
@Transactional(readOnly = false)
@Override
public boolean delete(final RegisteredService registeredService) {
if (this.entityManager.contains(registeredService)) {
......@@ -48,14 +45,12 @@ public final class JpaServiceRegistryDaoImpl implements ServiceRegistryDao {
return true;
}
@Transactional(readOnly = true)
@Override
public List<RegisteredService> load() {
return this.entityManager.createQuery("select r from AbstractRegisteredService r", RegisteredService.class)
.getResultList();
}
@Transactional(readOnly = false)
@Override
public RegisteredService save(final RegisteredService registeredService) {
final boolean isNew = registeredService.getId() == RegisteredService.INITIAL_IDENTIFIER_VALUE;
......@@ -69,7 +64,6 @@ public final class JpaServiceRegistryDaoImpl implements ServiceRegistryDao {
return r;
}
@Transactional(readOnly = true)
@Override
public RegisteredService findServiceById(final long id) {
return this.entityManager.find(AbstractRegisteredService.class, id);
......
......@@ -32,7 +32,6 @@ import org.jasig.cas.ticket.ServiceTicket;
import org.jasig.cas.ticket.ServiceTicketImpl;
import org.jasig.cas.ticket.Ticket;
import org.jasig.cas.ticket.TicketGrantingTicketImpl;
import org.springframework.transaction.annotation.Transactional;
/**
* JPA implementation of a CAS {@link TicketRegistry}. This implementation of
......@@ -53,21 +52,18 @@ public final class JpaTicketRegistry extends AbstractDistributedTicketRegistry {
@NotNull
private String ticketGrantingTicketPrefix = "TGT";
@Transactional(readOnly = false)
@Override
protected void updateTicket(final Ticket ticket) {
entityManager.merge(ticket);
logger.debug("Updated ticket [{}].", ticket);
}
@Transactional(readOnly = false)
@Override
public void addTicket(final Ticket ticket) {
entityManager.persist(ticket);
logger.debug("Added ticket [{}] to registry.", ticket);
}
@Transactional(readOnly = false)
@Override
public boolean deleteTicket(final String ticketId) {
final Ticket ticket = getRawTicket(ticketId);
......@@ -133,7 +129,6 @@ public final class JpaTicketRegistry extends AbstractDistributedTicketRegistry {
}
}
@Transactional(readOnly=true)
@Override
public Ticket getTicket(final String ticketId) {
return getProxiedTicketInstance(getRawTicket(ticketId));
......@@ -148,7 +143,7 @@ public final class JpaTicketRegistry extends AbstractDistributedTicketRegistry {
private Ticket getRawTicket(final String ticketId) {
try {
if (ticketId.startsWith(this.ticketGrantingTicketPrefix)) {
return entityManager.find(TicketGrantingTicketImpl.class, ticketId, LockModeType.PESSIMISTIC_WRITE);
return entityManager.find(TicketGrantingTicketImpl.class, ticketId);
}
return entityManager.find(ServiceTicketImpl.class, ticketId);
......@@ -158,7 +153,6 @@ public final class JpaTicketRegistry extends AbstractDistributedTicketRegistry {
return null;
}
@Transactional(readOnly=true)
@Override
public Collection<Ticket> getTickets() {
final List<TicketGrantingTicketImpl> tgts = entityManager
......@@ -184,14 +178,12 @@ public final class JpaTicketRegistry extends AbstractDistributedTicketRegistry {
return false;
}
@Transactional(readOnly=true)
@Override
public int sessionCount() {
return countToInt(entityManager.createQuery(
"select count(t) from TicketGrantingTicketImpl t").getSingleResult());
}
@Transactional(readOnly=true)
@Override
public int serviceTicketCount() {
return countToInt(entityManager.createQuery("select count(t) from ServiceTicketImpl t").getSingleResult());
......
......@@ -21,7 +21,6 @@ package org.jasig.cas.ticket.registry.support;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.Column;
import javax.persistence.Entity;
......@@ -106,11 +105,8 @@ public class JpaLockingStrategy implements LockingStrategy {
this.lockTimeout = seconds;
}
/**
* {@inheritDoc}
**/
@Override
@Transactional(readOnly = false)
public boolean acquire() {
Lock lock;
try {
......@@ -140,11 +136,7 @@ public class JpaLockingStrategy implements LockingStrategy {
return result;
}
/**
* {@inheritDoc}
**/
@Override
@Transactional(readOnly = false)
public void release() {
final Lock lock = entityManager.find(Lock.class, applicationId, LockModeType.PESSIMISTIC_WRITE);
......@@ -169,7 +161,6 @@ public class JpaLockingStrategy implements LockingStrategy {
*
* @return Current lock owner or null if no one presently owns lock.
*/
@Transactional(readOnly = true)
public String getOwner() {
final Lock lock = entityManager.find(Lock.class, applicationId);
if (lock != null) {
......@@ -178,10 +169,6 @@ public class JpaLockingStrategy implements LockingStrategy {
return null;
}
/**
* {@inheritDoc}
*/
@Override
public String toString() {
return uniqueId;
......
......@@ -207,8 +207,10 @@ public class AuthenticationViaFormAction {
}
return newEvent(SUCCESS);
} catch (final AuthenticationException e) {
logger.debug(e.getMessage(), e);
return newEvent(AUTHENTICATION_FAILURE, e);
} catch (final Exception e) {
logger.debug(e.getMessage(), e);
return newEvent(ERROR, e);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment