@Override public TenantMetaData getTenantMetadata() { if (tenantAware.getCurrentTenant() == null) { throw new IllegalStateException("Tenant not set"); } return getTenantMetadata(tenantAware.getCurrentTenant()); }
@Override public TenantMetaData getTenantMetadata() { if (tenantAware.getCurrentTenant() == null) { throw new IllegalStateException("Tenant not set"); } return getTenantMetadata(tenantAware.getCurrentTenant()); }
@Override protected Collection<String> getCacheNames(final CacheOperationInvocationContext<?> context) { return super.getCacheNames(context).stream() .map(cacheName -> tenantAware.getCurrentTenant() + "." + cacheName).collect(Collectors.toList()); } }
/** * @return * @see org.springframework.cache.Cache#getName() */ @Override public String getName() { return tenantAware.getCurrentTenant() + "." + delegate.getName(); }
@Override public Optional<AbstractDbArtifact> loadArtifactBinary(final String sha1Hash) { return Optional.ofNullable(artifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), sha1Hash)); }
@Override public Collection<String> getCacheNames() { String currentTenant = tenantAware.getCurrentTenant(); if (isTenantInvalid(currentTenant)) { return Collections.emptyList(); } currentTenant = currentTenant.toUpperCase(); return getCacheNames(currentTenant); }
@Override public Collection<String> getCacheNames() { String currentTenant = tenantAware.getCurrentTenant(); if (isTenantInvalid(currentTenant)) { return Collections.emptyList(); } currentTenant = currentTenant.toUpperCase(); return getCacheNames(currentTenant); }
private void sendRolloutGroupDeletedEvents(final JpaRollout rollout) { final List<Long> groupIds = rollout.getRolloutGroups().stream().map(RolloutGroup::getId) .collect(Collectors.toList()); afterCommit.afterCommit(() -> groupIds.forEach(rolloutGroupId -> eventPublisher .publishEvent(new RolloutGroupDeletedEvent(tenantAware.getCurrentTenant(), rolloutGroupId, JpaRolloutGroup.class.getName(), bus.getId())))); }
private void sendRolloutGroupDeletedEvents(final JpaRollout rollout) { final List<Long> groupIds = rollout.getRolloutGroups().stream().map(RolloutGroup::getId) .collect(Collectors.toList()); afterCommit.afterCommit(() -> groupIds.forEach(rolloutGroupId -> eventPublisher .publishEvent(new RolloutGroupDeletedEvent(tenantAware.getCurrentTenant(), rolloutGroupId, JpaRolloutGroup.class.getName(), applicationContext.getId())))); }
@Override @Cacheable(value = "currentTenant", keyGenerator = "currentTenantKeyGenerator", cacheManager = "directCacheManager", unless = "#result == null") public String currentTenant() { final String initialTenantCreation = currentTenantCacheKeyGenerator.getCreateInitialTenant().get(); if (initialTenantCreation == null) { final TenantMetaData findByTenant = tenantMetaDataRepository .findByTenantIgnoreCase(tenantAware.getCurrentTenant()); return findByTenant != null ? findByTenant.getTenant() : null; } return initialTenantCreation; }
@Override @Cacheable(value = "currentTenant", keyGenerator = "currentTenantKeyGenerator", cacheManager = "directCacheManager", unless = "#result == null") public String currentTenant() { final String initialTenantCreation = currentTenantCacheKeyGenerator.getCreateInitialTenant().get(); if (initialTenantCreation == null) { final TenantMetaData findByTenant = tenantMetaDataRepository .findByTenantIgnoreCase(tenantAware.getCurrentTenant()); return findByTenant != null ? findByTenant.getTenant() : null; } return initialTenantCreation; }
@Override public Cache getCache(final String name) { String currentTenant = tenantAware.getCurrentTenant(); if (isTenantInvalid(currentTenant)) { return null; } currentTenant = currentTenant.toUpperCase(); return delegate.getCache(buildKey(currentTenant, name)); }
@Override public Cache getCache(final String name) { String currentTenant = tenantAware.getCurrentTenant(); if (isTenantInvalid(currentTenant)) { return null; } currentTenant = currentTenant.toUpperCase(); return delegate.getCache(buildKey(currentTenant, name)); }
@Override public void requestControllerAttributes(final String controllerId) { final JpaTarget target = getByControllerIdAndThrowIfNotFound(controllerId); target.setRequestControllerAttributes(true); eventPublisher.publishEvent(new TargetAttributesRequestedEvent(tenantAware.getCurrentTenant(), target.getId(), target.getControllerId(), target.getAddress() != null ? target.getAddress().toString() : null, JpaTarget.class.getName(), bus.getId())); }
@Override protected void doBegin(final Object transaction, final TransactionDefinition definition) { super.doBegin(transaction, definition); final String currentTenant = tenantAware.getCurrentTenant(); if (currentTenant != null) { final EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager .getResource(getEntityManagerFactory()); final EntityManager em = emHolder.getEntityManager(); em.setProperty(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT, currentTenant.toUpperCase()); } } }
private void requestControllerAttributes(final String controllerId) { final JpaTarget target = (JpaTarget) getByControllerId(controllerId) .orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId)); target.setRequestControllerAttributes(true); eventPublisher.publishEvent(new TargetAttributesRequestedEvent(tenantAware.getCurrentTenant(), target.getId(), target.getControllerId(), target.getAddress() != null ? target.getAddress().toString() : null, JpaTarget.class.getName(), bus.getId())); }
@Override public void requestControllerAttributes(final String controllerId) { final JpaTarget target = getByControllerIdAndThrowIfNotFound(controllerId); target.setRequestControllerAttributes(true); eventPublisher.publishEvent(new TargetAttributesRequestedEvent(tenantAware.getCurrentTenant(), target.getId(), target.getControllerId(), target.getAddress() != null ? target.getAddress().toString() : null, JpaTarget.class.getName(), applicationContext.getId())); }
@Override protected void doBegin(final Object transaction, final TransactionDefinition definition) { super.doBegin(transaction, definition); final String currentTenant = tenantAware.getCurrentTenant(); if (currentTenant != null) { final EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager .getResource(getEntityManagerFactory()); final EntityManager em = emHolder.getEntityManager(); em.setProperty(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT, currentTenant.toUpperCase()); } } }
@Override @Transactional(propagation = Propagation.REQUIRES_NEW) public TenantUsage getStatsOfTenant() { final String tenant = tenantAware.getCurrentTenant(); final TenantUsage result = new TenantUsage(tenant); result.setTargets(targetRepository.count()); result.setArtifacts(artifactRepository.countBySoftwareModuleDeleted(false)); artifactRepository.getSumOfUndeletedArtifactSize().ifPresent(result::setOverallArtifactVolumeInBytes); result.setActions(actionRepository.count()); return result; }
@Override @Transactional(propagation = Propagation.REQUIRES_NEW) public TenantUsage getStatsOfTenant() { final String tenant = tenantAware.getCurrentTenant(); final TenantUsage result = new TenantUsage(tenant); result.setTargets(targetRepository.count()); result.setArtifacts(artifactRepository.countBySoftwareModuleDeleted(false)); artifactRepository.getSumOfUndeletedArtifactSize().ifPresent(result::setOverallArtifactVolumeInBytes); result.setActions(actionRepository.count()); return result; }