org.springframework.transaction.annotation.Isolation Java Examples

The following examples show how to use org.springframework.transaction.annotation.Isolation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PhotoHelperService.java    From xmfcn-spring-cloud with Apache License 2.0 6 votes vote down vote up
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, isolation = Isolation.REPEATABLE_READ, timeout = 30, rollbackFor = Exception.class)
public Photo save(Photo photo) throws Exception {
    Photo ret = null;
    if (photo == null) {
        return ret;
    }
    if (photo.getId() != null && photo.getId() > 0) {
        updateById(photo);
        ret = photo;
    } else {
        photo.setId(null);
        photoDao.add(photo);
        ret = photo;
    }
    return ret;
}
 
Example #2
Source File: Category1ServiceImpl.java    From product-recommendation-system with MIT License 6 votes vote down vote up
@Override
@Transactional(isolation=Isolation.DEFAULT, propagation=Propagation.REQUIRED)
public boolean removeCategory1(Long category1Id) {
	// 默认没有子类目
	Category1ServiceImpl.childFlag = false;
	
	if (category1Id == null) {
		return false;
	}
	// 在删除一级类目之前先判断一级类目下是否有子类目
	int category2Num = this.category2Mapper.countCategory2UnderCategory1(category1Id);
	if (category2Num > 0) {
		// 存在二级类目则不能删除一级类目
		Category1ServiceImpl.childFlag = true;
		return false;
	}
	
	int rows = this.category1Mapper.removeCategory1(category1Id);
	
	if (rows > 0) {
		return true;
	}
	
	return false;
}
 
Example #3
Source File: DefaultInterpretationService.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
@Transactional( isolation = Isolation.REPEATABLE_READ )
public boolean likeInterpretation( long id )
{
    Interpretation interpretation = getInterpretation( id );

    if ( interpretation == null )
    {
        return false;
    }

    User user = currentUserService.getCurrentUser();

    if ( user == null )
    {
        return false;
    }

    boolean userLike = interpretation.like( user );
    notifySubscribers( interpretation, null, NotificationType.INTERPRETATION_LIKE );

    return userLike;
}
 
Example #4
Source File: DefaultInterpretationService.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
@Transactional( isolation = Isolation.REPEATABLE_READ )
public boolean unlikeInterpretation( long id )
{
    Interpretation interpretation = getInterpretation( id );

    if ( interpretation == null )
    {
        return false;
    }

    User user = currentUserService.getCurrentUser();

    if ( user == null )
    {
        return false;
    }

    return interpretation.unlike( user );
}
 
Example #5
Source File: DefaultProviderDataAccessor.java    From blackduck-alert with Apache License 2.0 6 votes vote down vote up
@Override
@Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED)
public Set<String> getEmailAddressesForProjectHref(String projectHref) {
    Optional<Long> projectId = providerProjectRepository.findFirstByHref(projectHref).map(ProviderProjectEntity::getId);
    if (projectId.isPresent()) {
        Set<Long> userIds = providerUserProjectRelationRepository.findByProviderProjectId(projectId.get())
                                .stream()
                                .map(ProviderUserProjectRelation::getProviderUserId)
                                .collect(Collectors.toSet());
        return providerUserRepository.findAllById(userIds)
                   .stream()
                   .map(ProviderUserEntity::getEmailAddress)
                   .collect(Collectors.toSet());
    }
    return Set.of();
}
 
Example #6
Source File: ZKV4ConfigServiceImpl.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Override
@Transactional(isolation = Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public ConsoleBaseResponse<?> pushGroupByCluster(String clusterName) throws Exception {
    Cluster cluster = clusterService.findByClusterName(clusterName);
    if (cluster == null) {
        return ConsoleBaseResponse.error(ConsoleBaseResponse.Status.INVALID_PARAM, "集群不存在");
    }
    List<ConsumeGroup> list = consumeGroupService.findByClusterId(cluster.getId());
    if (CollectionUtils.isEmpty(list)) {
        return ConsoleBaseResponse.error(ConsoleBaseResponse.Status.INVALID_PARAM, "集群暂无订阅");
    }

    Set<Long> clusters = Sets.newHashSet();
    for (ConsumeGroup group : list) {
        List<ConsumeSubscription> subList = consumeSubscriptionService.findByGroupId(group.getId());

        clusters.addAll(subList.stream().map(ConsumeSubscription::getClusterId).collect(Collectors.toSet()));
        updateSubConfig(group.getId(), null);
    }

    updateCProxyConfigByClusterId("pushGroupByCluster", clusters);
    return ConsoleBaseResponse.success();
}
 
Example #7
Source File: ZKV4ConfigServiceImpl.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Override
@Transactional(isolation = Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public ConsoleBaseResponse<?> pushPProxyByCluster(String clusterName) throws Exception {
    Cluster cluster = clusterService.findByClusterName(clusterName);
    if (cluster == null) {
        return ConsoleBaseResponse.error(ConsoleBaseResponse.Status.INVALID_PARAM, "集群不存在");
    }
    List<Node> list = nodeService.findByClusterIdNodeType(cluster.getId(), NodeType.PRODUCER_PROXY);
    if (CollectionUtils.isEmpty(list)) {
        return ConsoleBaseResponse.error(ConsoleBaseResponse.Status.INVALID_PARAM, "集群暂无PProxy");
    }

    for (Node node : list) {
        updatePProxyConfig(node.getId());
    }
    return ConsoleBaseResponse.success();
}
 
Example #8
Source File: UserServiceImpl.java    From retro-game with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
@Transactional(isolation = Isolation.SERIALIZABLE)
public void disableVacationMode() {
  long userId = CustomUser.getCurrentUserId();
  User user = userRepository.getOne(userId);

  if (!canDisableVacationMode(user)) {
    // A hacking attempt, the button should be disabled.
    logger.warn("Disabling vacation mode failed, requirements not met: userId={}", userId);
    throw new CannotDisableVacationModeException();
  }

  logger.info("Disabling vacation mode: userId={}", userId);

  Date now = Date.from(Instant.ofEpochSecond(Instant.now().getEpochSecond()));

  // Bodies must be updated before vacation until is set, otherwise resources will be calculated incorrectly.
  updateActivitiesAndBodies(user, now);
  user.setVacationUntil(null);
  user.setForcedVacation(false);
}
 
Example #9
Source File: TopicServiceImpl.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Override
@Transactional(isolation = Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public ConsoleBaseResponse<?> addPProxy(String topicName, String clusterName, String host) throws Exception {
    Topic topic = findByTopicName(topicName);
    if (topic == null) {
        return ConsoleBaseResponse.error(ConsoleBaseResponse.Status.INVALID_PARAM, "topic not found");
    }
    Cluster cluster = clusterService.findByClusterName(clusterName);
    if (cluster == null) {
        return ConsoleBaseResponse.error(ConsoleBaseResponse.Status.INVALID_PARAM, "cluster not found");
    }
    if (!validNodeExist(host, cluster)) {
        return ConsoleBaseResponse.error(ConsoleBaseResponse.Status.INVALID_PARAM, "host not found");
    }

    List<TopicConf> confList = topicConfService.findByTopicClusterId(topic.getId(), cluster.getId());
    if (CollectionUtils.isEmpty(confList)) {
        return ConsoleBaseResponse.error(ConsoleBaseResponse.Status.INVALID_PARAM, "topic conf not found");
    }

    addPProxy(host, confList);

    return ConsoleBaseResponse.success();
}
 
Example #10
Source File: UEditorFileUploadCheck.java    From sanshanblog with Apache License 2.0 6 votes vote down vote up
@Transactional(isolation = Isolation.READ_COMMITTED,propagation = Propagation.REQUIRES_NEW,rollbackFor = Exception.class)
public void check(){
   Map<String,Integer> fileQuoteMap= redisTemplate.opsForHash().entries(UEditorFileService.UEDITOR_UPLOAD_FILE);
   //首先检查引用为0的 然后查看引用0的在UEDITOR_UPLOAD_TEMP_FILE缓存中是否存在
    for(Map.Entry<String,Integer> entry:fileQuoteMap.entrySet()){
        if (entry.getValue().equals(0)) {
            Boolean contain = redisTemplate.opsForValue().get(UEditorFileService.UEDITOR_UPLOAD_TEMP_FILE+entry.getKey()) != null ? true : false;
            //不包含的情况
            if (!contain){
                redisTemplate.opsForHash().delete(UEditorFileService.UEDITOR_UPLOAD_FILE, entry.getKey());
                UEditorFileQuoteMapper.deleteByFilename(entry.getKey());
                redisTemplate.opsForSet().remove(UEditorFileService.UEDITOR_TMEP_FILENAME_SET, entry.getKey());
                UEditorFileService.deleteFile(entry.getKey());
            }
        }
    }
}
 
Example #11
Source File: DbSegmentIdServiceImpl.java    From tinyid with Apache License 2.0 6 votes vote down vote up
/**
 * Transactional标记保证query和update使用的是同一连接
 * 事务隔离级别应该为READ_COMMITTED,Spring默认是DEFAULT(取决于底层使用的数据库,mysql的默认隔离级别为REPEATABLE_READ)
 * <p>
 * 如果是REPEATABLE_READ,那么在本次事务中循环调用tinyIdInfoDAO.queryByBizType(bizType)获取的结果是没有变化的,也就是查询不到别的事务提交的内容
 * 所以多次调用tinyIdInfoDAO.updateMaxId也就不会成功
 *
 * @param bizType
 * @return
 */
@Override
@Transactional(isolation = Isolation.READ_COMMITTED)
public SegmentId getNextSegmentId(String bizType) {
    // 获取nextTinyId的时候,有可能存在version冲突,需要重试
    for (int i = 0; i < Constants.RETRY; i++) {
        TinyIdInfo tinyIdInfo = tinyIdInfoDAO.queryByBizType(bizType);
        if (tinyIdInfo == null) {
            throw new TinyIdSysException("can not find biztype:" + bizType);
        }
        Long newMaxId = tinyIdInfo.getMaxId() + tinyIdInfo.getStep();
        Long oldMaxId = tinyIdInfo.getMaxId();
        int row = tinyIdInfoDAO.updateMaxId(tinyIdInfo.getId(), newMaxId, oldMaxId, tinyIdInfo.getVersion(),
                tinyIdInfo.getBizType());
        if (row == 1) {
            tinyIdInfo.setMaxId(newMaxId);
            SegmentId segmentId = convert(tinyIdInfo);
            logger.info("getNextSegmentId success tinyIdInfo:{} current:{}", tinyIdInfo, segmentId);
            return segmentId;
        } else {
            logger.info("getNextSegmentId conflict tinyIdInfo:{}", tinyIdInfo);
        }
    }
    throw new TinyIdSysException("get next segmentId conflict");
}
 
Example #12
Source File: DocumentServiceImpl.java    From AIDR with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public List<DocumentDTO> getDocumentForOneTask(Long crisisID, int count, String userName) {
	//logger.info("getDocumentForOneTask is called");
	/*
	List<DocumentDTO> documents = null;
	Users users = usersService.findUserByName(userName);
	if(users != null){
		documents =  this.getAvailableDocument(crisisID, count) ;
		System.out.println("For crisisID = " + crisisID + ", user = " + userName + ", documents available: " + (documents != null ? documents.size() : "empty list"));
		if(documents != null && documents.size() > 0){
			taskAssignmentService.addToTaskAssignment(documents, users.getUserID());
			System.out.println("Added to task_assignment table: " + documents.size() + "docID = " + documents.get(0).getDocumentID());
		}
	}
	*/
	List<DocumentDTO> documents = taskManager.getDocumentsForTagging(crisisID, count, userName, 0);
	logger.info("For crisisID = " + crisisID + ", user = " + userName + ", documents available for tagging: " + (documents != null ? documents.size() : "empty list"));
	return documents;  //To change body of implemented methods use File | Settings | File Templates.
}
 
Example #13
Source File: BaseService.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@ServiceMethodAuthority(type={ServiceMethodType.SELECT})
@Transactional(
		propagation=Propagation.REQUIRES_NEW, 
		isolation=Isolation.READ_COMMITTED, timeout=25, readOnly=true)	
public List<T> findListVOByParams(Map<String, Object> params) throws ServiceException, Exception {
	
	List<T> returnList = null;
	List<E> searchList = findListByParams(params, null);
	if (searchList==null || searchList.size()<1) {
		return returnList;
	}
	returnList=new ArrayList<T>();
	for (E entity : searchList) {
		Class<T> objectClass=GenericsUtils.getSuperClassGenricType(getClass(), 0);
		T obj=objectClass.newInstance();	
		this.doMapper(entity, obj, this.getMapperIdPo2Vo());
		returnList.add(obj);
	}
	return returnList;
}
 
Example #14
Source File: UserDao.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
/**
 * User can modify own setting, this method ensures that only such properties will be updated, the user's are allowed to.
 * @param user
 */
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.REPEATABLE_READ)
public void updateMyAccount(final PFUserDO user)
{
  accessChecker.checkRestrictedOrDemoUser();
  final PFUserDO contextUser = PFUserContext.getUser();
  Validate.isTrue(user.getId().equals(contextUser.getId()) == true);
  final PFUserDO dbUser = getHibernateTemplate().load(clazz, user.getId(), LockMode.PESSIMISTIC_WRITE);
  if (copyValues(user, dbUser, "deleted", "password", "lastLogin", "loginFailures", "username", "stayLoggedInKey", "authenticationToken",
      "rights") != ModificationStatus.NONE) {
    dbUser.setLastUpdate();
    log.info("Object updated: " + dbUser.toString());
    copyValues(user, contextUser, "deleted", "password", "lastLogin", "loginFailures", "username", "stayLoggedInKey",
        "authenticationToken", "rights");
  } else {
    log.info("No modifications detected (no update needed): " + dbUser.toString());
  }
  userGroupCache.updateUser(user);
}
 
Example #15
Source File: ZKV4ConfigServiceImpl.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Override
@Transactional(isolation = Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public ConsoleBaseResponse<?> pushPproxyConfig(String host) throws Exception {
    List<Node> nodeList = nodeService.findByHostNodeType(host, NodeType.PRODUCER_PROXY);
    if (CollectionUtils.isEmpty(nodeList)) {
        nodeList = nodeService.findByHostNodeType(HostUtils.getIp(host), NodeType.PRODUCER_PROXY);
    }

    if (CollectionUtils.isEmpty(nodeList)) {
        LOGGER.warn("[ZK_V4] not found pproxy node, host={}", host);
        return ConsoleBaseResponse.error(ConsoleBaseResponse.Status.INVALID_PARAM, "host不存在");
    }
    updatePProxyConfig(nodeList.get(0).getId());

    return ConsoleBaseResponse.success();
}
 
Example #16
Source File: ZKV4ConfigServiceImpl.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Override
@Transactional(isolation = Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public ConsoleBaseResponse<?> pushCProxyByCluster(String clusterName) throws Exception {
    Cluster cluster = clusterService.findByClusterName(clusterName);
    if (cluster == null) {
        return ConsoleBaseResponse.error(ConsoleBaseResponse.Status.INVALID_PARAM, "集群不存在");
    }
    List<Node> list = nodeService.findByClusterIdNodeType(cluster.getId(), NodeType.CONSUMER_PROXY);
    if (CollectionUtils.isEmpty(list)) {
        return ConsoleBaseResponse.error(ConsoleBaseResponse.Status.INVALID_PARAM, "集群暂无CProxy");
    }

    for (Node node : list) {
        updateCProxyConfig(node.getId());
    }
    return ConsoleBaseResponse.success();
}
 
Example #17
Source File: WinnersListHelperService.java    From xmfcn-spring-cloud with Apache License 2.0 6 votes vote down vote up
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, isolation = Isolation.REPEATABLE_READ, timeout = 30, rollbackFor = Exception.class)
public WinnersList save(WinnersList winnersList) throws Exception {
    WinnersList ret = null;
    if (winnersList == null) {
        return ret;
    }
    if (winnersList.getId() != null && winnersList.getId() > 0) {
        updateById(winnersList);
        ret = winnersList;
    } else {
        winnersList.setId(null);
        winnersListDao.add(winnersList);
        ret = winnersList;
    }
    return ret;
}
 
Example #18
Source File: SimpleService.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@ServiceMethodAuthority(type={ServiceMethodType.SELECT})
@Transactional(
		propagation=Propagation.REQUIRES_NEW, 
		isolation=Isolation.READ_COMMITTED, timeout=25, readOnly=true)
public DefaultResult<E> findEntityByOid(E object) throws ServiceException, Exception {		
	if (object==null || !(object instanceof BaseEntity) ) {
		throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL));
	}
	DefaultResult<E> result=new DefaultResult<E>();
	try {			
		E entityObject=this.findByOid(object);	
		if (entityObject!=null && !StringUtils.isBlank( ((BaseEntity<String>)entityObject).getOid() ) ) {
			result.setValue(entityObject);
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	if (result.getValue() == null) {
		result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA)));
	}
	return result;
}
 
Example #19
Source File: TaskAssignmentServiceImpl.java    From AIDR with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
 @Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
 public void revertTaskAssignmentByUserName(Long documentID, String userName) {
     /*
 	Users users = usersDao.findUserByName(userName);
     if(users!= null){
         Long userID = users.getUserID();
        // System.out.println("userID : " + userID);
         taskAssignmentDao.undoTaskAssignment(documentID,userID);
     }
     */
 	Users users = null;
users = usersService.findUserByName(userName);
     if(users!= null){
         Long userID = users.getId();
         //System.out.println("userID : " + userID);
         //taskAssignmentDao.undoTaskAssignment(documentID,userID);
         try {
	taskManager.undoTaskAssignment(documentID, userID);
} catch (Exception e) {
	logger.error(" Error in revertTaskAssignmentByUserName for User: "+userName+"\t"+e.getStackTrace());
}
     }
 }
 
Example #20
Source File: UserServiceImpl.java    From retro-game with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
@Transactional(isolation = Isolation.SERIALIZABLE)
public void unban(String name) {
  long adminId = CustomUser.getCurrentUserId();

  Optional<User> userOptional = userRepository.findByNameIgnoreCase(name);
  if (!userOptional.isPresent()) {
    logger.info("Unbanning user failed, user doesn't exist: adminId={}", adminId);
    throw new UserDoesntExistException();
  }
  User user = userOptional.get();

  if (!isBanned(user)) {
    logger.info("Unbanning user failed, user is not banned: adminId={} userId={}", adminId, user.getId());
    throw new UserNotBannedException();
  }

  logger.info("Unbanning user: adminId={} userId={}", adminId, user.getId());

  prangerServiceInternal.deleteEntry(user, user.getVacationUntil());

  Date now = Date.from(Instant.ofEpochSecond(Instant.now().getEpochSecond()));
  user.setVacationUntil(now);
  user.setForcedVacation(false);
}
 
Example #21
Source File: ZKV4ConfigServiceImpl.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Override
@Transactional(isolation = Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public ConsoleBaseResponse<?> pushPProxyByCluster(String clusterName) throws Exception {
    Cluster cluster = clusterService.findByClusterName(clusterName);
    if (cluster == null) {
        return ConsoleBaseResponse.error(ConsoleBaseResponse.Status.INVALID_PARAM, "集群不存在");
    }
    List<Node> list = nodeService.findByClusterIdNodeType(cluster.getId(), NodeType.PRODUCER_PROXY);
    if (CollectionUtils.isEmpty(list)) {
        return ConsoleBaseResponse.error(ConsoleBaseResponse.Status.INVALID_PARAM, "集群暂无PProxy");
    }

    for (Node node : list) {
        updatePProxyConfig(node.getId());
    }
    return ConsoleBaseResponse.success();
}
 
Example #22
Source File: BaseService.java    From bamboobsc with Apache License 2.0 5 votes vote down vote up
@Transactional(isolation=Isolation.READ_COMMITTED, timeout=25, readOnly=true)
public DefaultResult<E> ibatisSelectOneByValue(E valueObj) throws ServiceException, Exception {
	if (null==valueObj) {
		throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL));
	}
	DefaultResult<E> result = new DefaultResult<E>();
	E searchResult = this.getBaseDataAccessObject().ibatisSelectOneByValue(valueObj);
	if (searchResult!=null) {
		result.setValue(searchResult);
	} else {
		result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA)));
	}		
	return result;
}
 
Example #23
Source File: BaseDao.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Object will be marked as deleted (booelan flag), therefore undelete is always possible without any loss of data.
 * @param obj
 */
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.REPEATABLE_READ)
public void undelete(final O obj) throws AccessException
{
  Validate.notNull(obj);
  if (obj.getId() == null) {
    final String msg = "Could not undelete object unless id is not given:" + obj.toString();
    log.error(msg);
    throw new RuntimeException(msg);
  }
  checkLoggedInUserInsertAccess(obj);
  accessChecker.checkRestrictedOrDemoUser();
  internalUndelete(obj);
}
 
Example #24
Source File: PersonalAddressDao.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param obj
 * @return the generated identifier.
 */
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.REPEATABLE_READ)
public Serializable saveOrUpdate(final PersonalAddressDO obj)
{
  if (internalUpdate(obj) == true) {
    return obj.getId();
  }
  return internalSave(obj);
}
 
Example #25
Source File: TopicServiceImpl.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Override
@Transactional(isolation = Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public ConsoleBaseResponse<?> removePProxy(String host) throws Exception {
    List<TopicConf> confList = topicConfService.findAll();
    removePProxy(host, confList);

    return ConsoleBaseResponse.success();
}
 
Example #26
Source File: UserServiceImpl.java    From PedestrianDetectionSystem with Apache License 2.0 5 votes vote down vote up
@Override
@Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED)
public boolean loginUser(String username, String password) {
    User user = new User();
    user.setUsername(username);
    user.setPassword(password);
    User user1 = userMapper.selectUser(user);
    if (user1 != null) {
        return true;
    } else {
        return false;
    }
}
 
Example #27
Source File: BaseDao.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 
 * @param obj
 * @return the generated identifier.
 * @throws AccessException
 */
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.REPEATABLE_READ)
public Serializable save(final O obj) throws AccessException
{
  Validate.notNull(obj);
  if (avoidNullIdCheckBeforeSave == false) {
    Validate.isTrue(obj.getId() == null);
  }
  checkLoggedInUserInsertAccess(obj);
  accessChecker.checkRestrictedOrDemoUser();
  return internalSave(obj);
}
 
Example #28
Source File: ConsumeSubscriptionServiceImpl.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Override
@Transactional(isolation = Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public ConsoleBaseResponse<?> removeCProxy(String groupName, String host) throws Exception {
    ConsumeGroup group = consumeGroupService.findByGroupName(groupName);
    if (group == null) {
        return ConsoleBaseResponse.error(ConsoleBaseResponse.Status.INVALID_PARAM, "groupName not found");
    }
    List<ConsumeSubscription> subList = findByGroupId(group.getId());
    if (CollectionUtils.isEmpty(subList)) {
        return ConsoleBaseResponse.error(ConsoleBaseResponse.Status.INVALID_PARAM, "subscription not found");
    }
    removeCProxy(host, subList);

    return ConsoleBaseResponse.success();
}
 
Example #29
Source File: DocumentServiceImpl.java    From AIDR with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public List<DocumentDTO> getDocumentForTask(Long crisisID, int count, String userName) {

	if(count>CodeLookUp.DOCUMENT_MAX_FETCH_COUNT){
		count = CodeLookUp.DOCUMENT_MAX_FETCH_COUNT;
	}
	
	List<DocumentDTO> documents = taskManager.getDocumentsForTagging(crisisID, count, userName, CodeLookUp.DOCUMENT_REMAINING_COUNT);
	logger.info("For crisisID = " + crisisID + ", user = " + userName + ", documents available for tagging: " + (documents != null ? documents.size() : "empty list"));
	return documents;  
}
 
Example #30
Source File: TransactiveService.java    From mybatis.flying with Apache License 2.0 5 votes vote down vote up
@Transactional(rollbackFor = {
		ConfigurerException.class }, readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED)
public void addAccountTransactive() throws ConfigurerException {
	Role_ role2 = new Role_();
	role2.setName("role_");
	roleService.insert(role2);
	throw new ConfigurerException("qwe");
}