EntityLockingServiceImpl.java 文件源码

java
阅读 26 收藏 0 点赞 0 评论 0

项目:Equella 作者:
@Override
@Transactional(propagation = Propagation.MANDATORY)
public EntityLock getLock(BaseEntity entity, String lockId)
{
    EntityLock lock = entityLockDao.findByCriteria(Restrictions.eq("entity", entity));
    if( lock != null )
    {
        if( lockId == null )
        {
            throw new LockedException("Entity is locked by another user '" + lock.getUserID() + "'",
                lock.getUserID(), lock.getUserSession(), entity.getId());
        }
        if( !lockId.equals(lock.getUserSession()) )
        {
            throw new LockedException("Wrong lock id. Entity is locked by user.", lock.getUserID(),
                lock.getUserSession(), entity.getId());
        }
    }
    else if( lockId != null )
    {
        throw new LockedException("Entity is not locked", null, null, entity.getId());
    }
    return lock;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号