Merge pull request #157 from bsinno/fix_tenant_unknown_exception_for_rollout_scheduler

remove current tenant null check
This commit is contained in:
Kai Zimmermann
2016-04-29 10:20:14 +02:00

View File

@@ -11,7 +11,6 @@ package org.eclipse.hawkbit;
import javax.persistence.EntityManager;
import javax.transaction.Transaction;
import org.eclipse.hawkbit.repository.exception.TenantNotExistException;
import org.eclipse.hawkbit.tenancy.TenantAware;
import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.springframework.beans.factory.annotation.Autowired;
@@ -36,16 +35,12 @@ public class MultiTenantJpaTransactionManager extends JpaTransactionManager {
protected void doBegin(final Object transaction, final TransactionDefinition definition) {
super.doBegin(transaction, definition);
final EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager
.getResource(getEntityManagerFactory());
final EntityManager em = emHolder.getEntityManager();
final String currentTenant = tenantAware.getCurrentTenant();
if (currentTenant == null) {
throw new TenantNotExistException("Tenant Unknown. Canceling transaction.");
if (currentTenant != null) {
final EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager
.getResource(getEntityManagerFactory());
final EntityManager em = emHolder.getEntityManager();
em.setProperty(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT, currentTenant.toUpperCase());
}
em.setProperty(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT, currentTenant.toUpperCase());
}
}