Java Code Examples for org.springframework.transaction.annotation.Propagation#REQUIRES_NEW

The following examples show how to use org.springframework.transaction.annotation.Propagation#REQUIRES_NEW . These examples are extracted from open source projects. 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 Project: herd   File: EmrServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * <p/>
 * This implementation starts a new transaction.
 */
@NamespacePermission(fields = "#request?.namespace", permissions = NamespacePermissionEnum.WRITE)
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public EmrMasterSecurityGroup addSecurityGroupsToClusterMaster(EmrMasterSecurityGroupAddRequest request) throws Exception
{
    return addSecurityGroupsToClusterMasterImpl(request);
}
 
Example 2
/**
 * 
 * @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 3
@NamespacePermission(fields = "#request.namespace", permissions = NamespacePermissionEnum.READ)
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public BusinessObjectDataDdl generateBusinessObjectDataDdl(BusinessObjectDataDdlRequest request)
{
    return generateBusinessObjectDataDdlImpl(request, false);
}
 
Example 4
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void add(AuditEvent event) {
    if (!AUTHORIZATION_FAILURE.equals(event.getType()) &&
        !Constants.ANONYMOUS_USER.equals(event.getPrincipal())) {

        PersistentAuditEvent persistentAuditEvent = new PersistentAuditEvent();
        persistentAuditEvent.setPrincipal(event.getPrincipal());
        persistentAuditEvent.setAuditEventType(event.getType());
        persistentAuditEvent.setAuditEventDate(event.getTimestamp());
        Map<String, String> eventData = auditEventConverter.convertDataToStrings(event.getData());
        persistentAuditEvent.setData(truncate(eventData));
        persistenceAuditEventRepository.save(persistentAuditEvent);
    }
}
 
Example 5
/**
 * {@inheritDoc}
 * <p/>
 * This implementation starts a new transaction.
 */
@PublishNotificationMessages
@NamespacePermission(fields = "#businessObjectDataStorageUnitKey.namespace", permissions = NamespacePermissionEnum.WRITE)
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public BusinessObjectDataStorageUnitStatusUpdateResponse updateBusinessObjectDataStorageUnitStatus(
    BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey, BusinessObjectDataStorageUnitStatusUpdateRequest request)
{
    return updateBusinessObjectDataStorageUnitStatusImpl(businessObjectDataStorageUnitKey, request);
}
 
Example 6
Source Project: olat   File: NotificationEventDao.java    License: Apache License 2.0 5 votes vote down vote up
@Retryable
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void updateEvents(List<NotificationEvent> events, NotificationEvent.Status status) {
    for (NotificationEvent event : events) {
        event = genericDao.findById(event.getId());
        event.setStatus(status);
        event.getSubscription().setLastNotifiedDate(new Date());
        updateEvent(event);
    }
}
 
Example 7
Source Project: syncope   File: JPAUserDAO.java    License: Apache License 2.0 5 votes vote down vote up
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true)
@Override
public Collection<ExternalResource> findAllResources(final User user) {
    Set<ExternalResource> result = new HashSet<>();
    result.addAll(user.getResources());
    findAllGroups(user).forEach(group -> result.addAll(group.getResources()));

    return result;
}
 
Example 8
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void add(AuditEvent event) {
    if (!AUTHORIZATION_FAILURE.equals(event.getType()) &&
        !Constants.ANONYMOUS_USER.equals(event.getPrincipal())) {

        PersistentAuditEvent persistentAuditEvent = new PersistentAuditEvent();
        persistentAuditEvent.setPrincipal(event.getPrincipal());
        persistentAuditEvent.setAuditEventType(event.getType());
        persistentAuditEvent.setAuditEventDate(event.getTimestamp());
        Map<String, String> eventData = auditEventConverter.convertDataToStrings(event.getData());
        persistentAuditEvent.setData(truncate(eventData));
        persistenceAuditEventRepository.save(persistentAuditEvent);
    }
}
 
Example 9
/**
 * Ohne Zugangsbegrenzung. Wird bei Anmeldung benötigt.
 * @param username
 * @param encryptedPassword
 * @return
 */
@SuppressWarnings("unchecked")
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW)
public PFUserDO authenticateUser(final String username, final String password)
{
  Validate.notNull(username);
  Validate.notNull(password);

  PFUserDO user = getUser(username, password, true);
  if (user != null) {
    final int loginFailures = user.getLoginFailures();
    final Timestamp lastLogin = user.getLastLogin();
    user.setLastLogin(new Timestamp(new Date().getTime()));
    user.setLoginFailures(0);
    user.setMinorChange(true); // Avoid re-indexing of all dependent objects.
    internalUpdate(user, false);
    if (user.hasSystemAccess() == false) {
      log.warn("Deleted/deactivated user tried to login: " + user);
      return null;
    }
    final PFUserDO contextUser = new PFUserDO();
    contextUser.copyValuesFrom(user);
    contextUser.setLoginFailures(loginFailures); // Restore loginFailures for current user session.
    contextUser.setLastLogin(lastLogin); // Restore lastLogin for current user session.
    contextUser.setPassword(null);
    return contextUser;
  }
  final List<PFUserDO> list = getHibernateTemplate().find("from PFUserDO u where u.username = ?", username);
  if (list != null && list.isEmpty() == false && list.get(0) != null) {
    user = list.get(0);
    user.setLoginFailures(user.getLoginFailures() + 1);
    internalUpdate(user);
  }
  return null;
}
 
Example 10
Source Project: onetwo   File: DbmSendMessageRepository.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@Transactional(propagation=Propagation.REQUIRES_NEW)
public void batchUpdateToSent(Collection<SendMessageContext<?>> ctxs) {
	List<SendMessageEntity> messages = ctxs.stream().map(ctx -> {
		SendMessageEntity e = ctx.getMessageEntity();
		e.setState(SendStates.SENT);
		return e;
	}).collect(Collectors.toList());
	getBaseEntityManager().getSessionFactory().getSession().batchUpdate(messages);
}
 
Example 11
/**
 * {@inheritDoc}
 * <p/>
 * This implementation starts a new transaction.
 */
@NamespacePermission(fields = "#businessObjectDataKey?.namespace", permissions = NamespacePermissionEnum.READ)
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public BusinessObjectDataAttributeKeys getBusinessObjectDataAttributes(BusinessObjectDataKey businessObjectDataKey)
{
    return getBusinessObjectDataAttributesImpl(businessObjectDataKey);
}
 
Example 12
@Override
@Transactional(value = "cacheTransactionManager", propagation=Propagation.REQUIRES_NEW, isolation = Isolation.READ_COMMITTED)
public void doRemoveRuleTag(final Long id, final ConfigurationElementReport elementReport) {
  LOGGER.trace("Removing RuleTag " + id);
  try {
    RuleTag ruleTag = tagCache.get(id);
    Collection<Long> ruleIds = ruleTag.getCopyRuleIds();  
    if (!ruleIds.isEmpty()) {
      LOGGER.debug("Removing rules dependent on RuleTag " + id);
      for (Long ruleId : ruleIds) { //concurrent modifcation as a rule is removed from the list during the remove call!
        if (tagLocationService.isInTagCache(ruleId)) { //may already have been removed if a previous rule in the list was used in this rule!
          ConfigurationElementReport newReport = new ConfigurationElementReport(Action.REMOVE, Entity.RULETAG, ruleId);
          elementReport.addSubReport(newReport);
          ruleTagConfigHandler.removeRuleTag(ruleId, newReport); //call config handler bean so transaction annotation is noticed
        }         
      }                
    }
    tagCache.acquireWriteLockOnKey(id);      
    Collection<Long> ruleInputTagIds = Collections.EMPTY_LIST;
    try {
      ruleInputTagIds = ruleTag.getCopyRuleInputTagIds();                
      Collection<Long> alarmIds = ruleTag.getCopyAlarmIds();                  
      if (!alarmIds.isEmpty()) {
        LOGGER.debug("Removing Alarms dependent on RuleTag " + id);
        for (Long alarmId : alarmIds) { //need copy as modified concurrently by remove alarm
          ConfigurationElementReport alarmReport = new ConfigurationElementReport(Action.REMOVE, Entity.ALARM, alarmId);
          elementReport.addSubReport(alarmReport);
          alarmConfigHandler.removeAlarm(alarmId, alarmReport);
        }        
      }
      for (Long inputTagId : ruleInputTagIds) {
        tagConfigGateway.removeRuleFromTag(inputTagId, id); //allowed to lock tag below the rule...
      }

      for (ConfigurationEventListener listener : configurationEventListeners) {
        listener.onConfigurationEvent(ruleTag, Action.REMOVE);
      }

      configurableDAO.deleteItem(ruleTag.getId());                                           
    }
    catch (RuntimeException rEx) {
      String errMessage = "Exception caught when removing rule tag with id " + id;
      LOGGER.error(errMessage, rEx); 
      throw new UnexpectedRollbackException(errMessage, rEx);   
    } finally {
      if (tagCache.isWriteLockedByCurrentThread(id)) {
        tagCache.releaseWriteLockOnKey(id);
      }        
    }
  } catch (CacheElementNotFoundException e) {
    LOGGER.debug("Attempting to remove a non-existent RuleTag - no action taken.");
    elementReport.setWarning("Attempting to removed a non-existent RuleTag");      
  }       
}
 
Example 13
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Modifying
@Query("update Check c set c.lastSentEmail = current_timestamp, currentErrorCount = 0 where c.id = ?1")
void emailSent(int checkId);
 
Example 14
Source Project: redisson   File: TransactionalBean2.java    License: Apache License 2.0 4 votes vote down vote up
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testInNewTransaction() {
    RTransaction transaction = transactionManager.getCurrentTransaction();
    transaction.getMap("tr2").put("2", "4");
}
 
Example 15
Source Project: zstack   File: SimpleQueryImpl.java    License: Apache License 2.0 4 votes vote down vote up
@Override
@Transactional(readOnly=true, propagation=Propagation.REQUIRES_NEW)
public T find() {
    return _find();
}
 
Example 16
Source Project: zstack   File: SimpleQueryImpl.java    License: Apache License 2.0 4 votes vote down vote up
@Override
@Transactional(readOnly=true, propagation=Propagation.REQUIRES_NEW)
public <K> List<K> listValue() {
    return _listValue();
}
 
Example 17
Source Project: transaction-test   File: User2ServiceImpl.java    License: MIT License 4 votes vote down vote up
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void addRequiresNewException(User2 user){
	user2Mapper.insert(user);
	throw new RuntimeException();
}
 
Example 18
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Modifying
@Query("update Check c set c.currentErrorCount = 0 where c.id = ?1")
void clearErrorCount(int checkId);
 
Example 19
@Override
@Transactional(value = "cacheTransactionManager", propagation = Propagation.REQUIRES_NEW)
public List<ProcessChange> doUpdateAbstractEquipment(final SubEquipment subEquipment, Properties properties) throws IllegalAccessException {
  return super.updateAbstractEquipment(subEquipment, properties);
}
 
Example 20
/**
 * Saves the given synchronizer's configuration back in the databse.
 * This method is intended to be used by Synchronizers themselves, this
 * method does no tests at all to avoid deadlocks.
 * <p>
 * This method is unsafe and you should probably be using
 * {@link #saveSynchronizerConf(SynchronizerConf)} instead.
 * @param s to save.
 */
@Override
@Transactional (propagation = Propagation.REQUIRES_NEW)
public void saveSynchronizer (Synchronizer s)
{
   this.synchronizerDao.update (s.getSynchronizerConf ());
}