Example usage for org.springframework.transaction.annotation Isolation DEFAULT

List of usage examples for org.springframework.transaction.annotation Isolation DEFAULT

Introduction

In this page you can find the example usage for org.springframework.transaction.annotation Isolation DEFAULT.

Prototype

Isolation DEFAULT

To view the source code for org.springframework.transaction.annotation Isolation DEFAULT.

Click Source Link

Document

Use the default isolation level of the underlying datastore.

Usage

From source file:org.trpr.platform.core.impl.persistence.PersistenceDelegate.java

/**
 * Deletes the specified PersistentEntity instances using the specified PersistenceProvider instances, matched by index positions. 
 * Note that this method is transactional by default.
 * It is advisable to use {@link PersistenceManagerProvider#makeTransient(PersistentEntity[])} instead of calling this method directly.
 * @param entities the PersistentEntity instances to delete
 * @param providers the PersistenceProvider instances to use in delete
 * @return  PersistentEntity instances that were deleted
 * @throws PersistenceException in case of deletion errors
 *///from  w  w  w.  java 2  s.c o  m
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.DEFAULT, rollbackForClassName = {
        "Exception" })
public void makeTransient(PersistentEntity[] entities, PersistenceProvider[] providers)
        throws PersistenceException {
    for (int i = 0; i < entities.length; i++) {
        providers[i].makeTransient(entities[i]);
    }
}

From source file:org.trpr.platform.core.impl.persistence.PersistenceDelegate.java

/**
 * Updates the underlying data store with information available in the specified Criteria using the specified PersistenceProvider
 * Note that this method is transactional by default.
 * It is advisable to use {@link PersistenceManagerProvider#update(Criteria)} instead of calling this method directly.    
 * @param criteria the Criteria instance containing update data fields and values
 * @param provider the PersistenceProvider to use for the persistence call
 * @return int identifying the success status of update operation
 * @throws PersistenceException in case of errors during persistence
 *//*www  . ja v  a  2s . c  o  m*/
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.DEFAULT, rollbackForClassName = {
        "Exception" })
public int update(Criteria criteria, PersistenceProvider provider) throws PersistenceException {
    return provider.update(criteria);
}

From source file:com.francetelecom.clara.cloud.environment.impl.ManageEnvironmentImpl.java

@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public EnvironmentDto findEnvironmentByUID(String uid) throws EnvironmentNotFoundException {
    Environment environment = environmentRepository.findByUid(uid);
    if (environment == null) {
        String message = "Environment with UID[" + uid + "] does not exist.";
        log.info(message);//from   ww  w.jav a2s  .co  m
        throw new EnvironmentNotFoundException(message);
    }

    // assert user is authorize to perform action
    assertHasReadPermissionFor(environment);

    return environmentMapper.toEnvironmentDto(environment);
}

From source file:com.francetelecom.clara.cloud.environment.impl.ManageEnvironmentImpl.java

@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public EnvironmentDetailsDto findEnvironmentDetails(String uid) throws EnvironmentNotFoundException {
    Environment environment = environmentRepository.findByUid(uid);
    if (environment == null) {
        String message = "Environment with UID[" + uid + "] does not exist.";
        log.info(message);/*from  w w w. j a v a2  s.c  om*/
        throw new EnvironmentNotFoundException(message);
    }

    assertHasReadPermissionFor(environment);

    return toEnvironmentDetailsDto(environment);
}

From source file:org.trpr.platform.core.impl.persistence.PersistenceDelegate.java

/**
 * Updates the underlying data store with information available in the specified Criteria instances using the specified PersistenceProvider
 * instances, with matching indexes. Note that this method is transactional by default.
 * It is advisable to use {@link PersistenceManagerProvider#update(Criteria...)} instead of calling this method directly.    
 * @param providers the PersistenceProvider instances to be used in persistence of the Criteria information, matched by indices
 * @param criteria the Criteria instances whose information must be persisted
 * @return int array containing the outcome status of update operation
 * @throws PersistenceException in case of peristence errors
 *///from   w  w  w.  ja  v  a  2  s  . c o m
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.DEFAULT, rollbackForClassName = {
        "Exception" })
public int[] update(PersistenceProvider[] providers, Criteria... criteria) throws PersistenceException {
    int[] returnValue = new int[criteria.length];
    for (int i = 0; i < criteria.length; i++) {
        returnValue[i] = providers[i].update(criteria[i]);
    }
    return returnValue;
}

From source file:com.francetelecom.clara.cloud.environment.impl.ManageEnvironmentImpl.java

@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public EnvironmentOpsDetailsDto findEnvironmentOpsDetailsByUID(String uid) throws EnvironmentNotFoundException {
    Environment environment = environmentRepository.findByUid(uid);
    if (environment == null) {
        String message = "Environment with UID[" + uid + "] does not exist.";
        log.info(message);// w ww.  ja v a 2  s.c  o m
        throw new EnvironmentNotFoundException(message);
    }

    assertHasReadPermissionFor(environment);

    return createEnvironmentOpsDetailsDto(environment);
}

From source file:com.francetelecom.clara.cloud.environment.impl.ManageEnvironmentImpl.java

@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public List<EnvironmentDto> findEnvironments() {
    if (securityUtils.currentUserIsAdmin()) {
        return environmentMapper.toEnvironmentDtoList(environmentRepository.findAllActive());
    } else {/* ww  w .j  av a2 s .  c  o m*/
        return environmentMapper.toEnvironmentDtoList(
                environmentRepository.findAllPublicOrPrivateByMember(securityUtils.currentUser().getValue()));
    }
}

From source file:com.francetelecom.clara.cloud.environment.impl.ManageEnvironmentImpl.java

@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public List<EnvironmentDto> findMyEnvironments() {
    return environmentMapper.toEnvironmentDtoList(
            environmentRepository.findAllActiveByApplicationMember(securityUtils.currentUser().getValue()));
}

From source file:com.francetelecom.clara.cloud.environment.impl.ManageEnvironmentImpl.java

@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public List<EnvironmentDto> findEnvironmentsByAppRelease(String releaseUID)
        throws ApplicationReleaseNotFoundException {
    ApplicationRelease applicationRelease = applicationReleaseRepository.findByUID(releaseUID);
    if (applicationRelease == null) {
        throw new ApplicationReleaseNotFoundException("ApplicationRelease#" + releaseUID);
    }//  w ww  . j  a  v a 2 s. c o  m
    // cannot see if not authorized
    if (securityUtils.currentUserIsAdmin()) {
        return environmentMapper
                .toEnvironmentDtoList(environmentRepository.findAllActiveByApplicationReleaseUid(releaseUID));
    } else {
        return environmentMapper.toEnvironmentDtoList(
                environmentRepository.findAllPublicOrPrivateByMemberAndByApplicationRelease(releaseUID,
                        securityUtils.currentUser().getValue()));
    }
}

From source file:com.francetelecom.clara.cloud.environment.impl.ManageEnvironmentImpl.java

@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public void startEnvironment(String uid) throws EnvironmentNotFoundException {
    try {/*from w w  w.  j a  v a 2  s.c  om*/
        MDC.put(LOG_KEY_ENVUID, uid);
        log.debug("startEnvironment: uid={}", new Object[] { uid });
        Environment environment = environmentRepository.findByUid(uid);
        assertHasWritePermissionFor(environment);
        MDC.put(LOG_KEY_ENVNAME, environment.getLabel());
        if (environment.isStopped()) {
            managePaasActivation.start(environment.getTechnicalDeploymentInstance().getId());
            // TODO status should be set by managePaasActivation
            environment.setStatus(EnvironmentStatus.STARTING);
        } else if (environment.isStarting() || environment.isRunning()) {
            log.info("Environment '" + environment.getUID()
                    + "' is already started or is starting (ignoring call)");
        } else if (environment.isFailed()) {
            log.warn("Environment '" + environment.getUID() + "' is failed but (anyway) we try to start it...");
            managePaasActivation.start(environment.getTechnicalDeploymentInstance().getId());
            // TODO status should be set by managePaasActivation
            environment.setStatus(EnvironmentStatus.STARTING);
        } else {
            throw new TechnicalException(
                    "Calling start on environment which has a bad status: " + environment.getStatus());
        }
    } finally {
        MDC.remove(LOG_KEY_ENVNAME);
        MDC.remove(LOG_KEY_ENVUID);
    }
}