Codota Logo
TenantAware
Code IndexAdd Codota to your IDE (free)

How to use
TenantAware
in
org.eclipse.hawkbit.tenancy

Best Java code snippets using org.eclipse.hawkbit.tenancy.TenantAware (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Dictionary d =
  • Codota Iconnew Hashtable()
  • Codota IconBundle bundle;bundle.getHeaders()
  • Codota Iconnew Properties()
  • Smart code suggestions by Codota
}
origin: eclipse/hawkbit

@Override
public Object generate(final Object target, final Method method, final Object... params) {
  return tenantAware.getCurrentTenant().toUpperCase();
}
origin: eclipse/hawkbit

@Override
public <E extends TenantAwareBaseEntity> E findEntity(final String tenant, final Long id,
    final Class<E> entityType) {
  return tenantAware.runAsTenant(tenant, () -> entityManager.find(entityType, id));
}
origin: org.eclipse.hawkbit/hawkbit-repository-jpa

@Override
public Object generate(final Object target, final Method method, final Object... params) {
  return tenantAware.getCurrentTenant().toUpperCase();
}
origin: org.eclipse.hawkbit/hawkbit-repository-jpa

@Override
public <E extends TenantAwareBaseEntity> E findEntity(final String tenant, final Long id,
    final Class<E> entityType) {
  return tenantAware.runAsTenant(tenant, () -> entityManager.find(entityType, id));
}
origin: org.eclipse.hawkbit/hawkbit-repository-jpa

@Override
public TenantMetaData getTenantMetadata() {
  if (tenantAware.getCurrentTenant() == null) {
    throw new IllegalStateException("Tenant not set");
  }
  return getTenantMetadata(tenantAware.getCurrentTenant());
}
origin: eclipse/hawkbit

@Override
public boolean isEnable(final DmfTenantSecurityToken secruityToken) {
  return tenantAware.runAsTenant(secruityToken.getTenant(), configurationKeyTenantRunner);
}
origin: eclipse/hawkbit

@Override
public TenantMetaData getTenantMetadata() {
  if (tenantAware.getCurrentTenant() == null) {
    throw new IllegalStateException("Tenant not set");
  }
  return getTenantMetadata(tenantAware.getCurrentTenant());
}
origin: eclipse/hawkbit

@Override
public Object getPreAuthenticatedCredentials(final DmfTenantSecurityToken secruityToken) {
  final String authorityNameConfigurationValue = tenantAware.runAsTenant(secruityToken.getTenant(),
      sslIssuerNameConfigTenantRunner);
  String controllerId = secruityToken.getControllerId();
  // in case of legacy download artifact, the controller ID is not in the
  // URL path, so then we just use the common name header
  if (controllerId == null || "anonymous".equals(controllerId)) {
    controllerId = secruityToken.getHeader(caCommonNameHeader);
  }
  final List<String> knownHashes = splitMultiHashBySemicolon(authorityNameConfigurationValue);
  final String cntlId = controllerId;
  return knownHashes.stream().map(hashItem -> new HeaderAuthentication(cntlId, hashItem))
      .collect(Collectors.toSet());
}
origin: org.eclipse.hawkbit/hawkbit-autoconfigure

  @Override
  protected Collection<String> getCacheNames(final CacheOperationInvocationContext<?> context) {
    return super.getCacheNames(context).stream()
        .map(cacheName -> tenantAware.getCurrentTenant() + "." + cacheName).collect(Collectors.toList());
  }
}
origin: eclipse/hawkbit

try {
  LOG.debug("entering system code execution");
  return tenantAware.runAsTenant(tenant, () -> {
    try {
      setSystemContext(SecurityContextHolder.getContext());
origin: org.eclipse.hawkbit/hawkbit-autoconfigure

/**
 * @return
 * @see org.springframework.cache.Cache#getName()
 */
@Override
public String getName() {
  return tenantAware.getCurrentTenant() + "." + delegate.getName();
}
origin: org.eclipse.hawkbit/hawkbit-repository-jpa

/**
 * Flush the update queue by means to persisting
 * {@link Target#getLastTargetQuery()}.
 */
private void flushUpdateQueue() {
  LOG.debug("Run flushUpdateQueue.");
  final int size = queue.size();
  if (size <= 0) {
    return;
  }
  LOG.debug("{} events in flushUpdateQueue.", size);
  final Set<TargetPoll> events = Sets.newHashSetWithExpectedSize(queue.size());
  final int drained = queue.drainTo(events);
  if (drained <= 0) {
    return;
  }
  try {
    events.stream().collect(Collectors.groupingBy(TargetPoll::getTenant)).forEach((tenant, polls) -> {
      final TransactionCallback<Void> createTransaction = status -> updateLastTargetQueries(tenant, polls);
      tenantAware.runAsTenant(tenant, () -> runInNewTransaction("flushUpdateQueue", createTransaction));
    });
  } catch (final RuntimeException ex) {
    LOG.error("Failed to persist UpdateQueue content.", ex);
    return;
  }
  LOG.debug("{} events persisted.", drained);
}
origin: org.eclipse.hawkbit/hawkbit-repository-jpa

@Override
public Optional<AbstractDbArtifact> loadArtifactBinary(final String sha1Hash) {
  return Optional.ofNullable(artifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), sha1Hash));
}
origin: eclipse/hawkbit

/**
 * Flush the update queue by means to persisting
 * {@link Target#getLastTargetQuery()}.
 */
private void flushUpdateQueue() {
  LOG.debug("Run flushUpdateQueue.");
  final int size = queue.size();
  if (size <= 0) {
    return;
  }
  LOG.debug("{} events in flushUpdateQueue.", size);
  final Set<TargetPoll> events = Sets.newHashSetWithExpectedSize(queue.size());
  final int drained = queue.drainTo(events);
  if (drained <= 0) {
    return;
  }
  try {
    events.stream().collect(Collectors.groupingBy(TargetPoll::getTenant)).forEach((tenant, polls) -> {
      final TransactionCallback<Void> createTransaction = status -> updateLastTargetQueries(tenant, polls);
      tenantAware.runAsTenant(tenant,
          () -> DeploymentHelper.runInNewTransaction(txManager, "flushUpdateQueue", createTransaction));
    });
  } catch (final RuntimeException ex) {
    LOG.error("Failed to persist UpdateQueue content.", ex);
    return;
  }
  LOG.debug("{} events persisted.", drained);
}
origin: org.eclipse.hawkbit/hawkbit-repository-jpa

  @Override
  // Exception squid:S923 - override
  @SuppressWarnings({ "squid:S923" })
  public Object generate(final Object target, final Method method, final Object... params) {
    final String initialTenantCreation = createInitialTenant.get();
    if (initialTenantCreation == null) {
      return SimpleKeyGenerator.generateKey(tenantAware.getCurrentTenant().toUpperCase(),
          tenantAware.getCurrentTenant().toUpperCase());
    }
    return SimpleKeyGenerator.generateKey(initialTenantCreation.toUpperCase(),
        initialTenantCreation.toUpperCase());
  }
}
origin: eclipse/hawkbit

@Override
public HeaderAuthentication getPreAuthenticatedCredentials(final DmfTenantSecurityToken secruityToken) {
  final String gatewayToken = tenantAware.runAsTenant(secruityToken.getTenant(),
      gatewaySecurityTokenKeyConfigRunner);
  return new HeaderAuthentication(secruityToken.getControllerId(), gatewayToken);
}
origin: eclipse/hawkbit

@Override
public Optional<AbstractDbArtifact> loadArtifactBinary(final String sha1Hash) {
  return Optional.ofNullable(artifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), sha1Hash));
}
origin: eclipse/hawkbit

@EventListener(classes = RolloutGroupDeletedEvent.class)
void invalidateCachedTotalTargetCountOnRolloutGroupDelete(final RolloutGroupDeletedEvent event) {
  final Cache cache = tenantAware.runAsTenant(event.getTenant(), () -> cacheManager.getCache(CACHE_GR_NAME));
  cache.evict(event.getEntityId());
}
origin: eclipse/hawkbit

  @Override
  // Exception squid:S923 - override
  @SuppressWarnings({ "squid:S923" })
  public Object generate(final Object target, final Method method, final Object... params) {
    final String initialTenantCreation = createInitialTenant.get();
    if (initialTenantCreation == null) {
      return SimpleKeyGenerator.generateKey(tenantAware.getCurrentTenant().toUpperCase(),
          tenantAware.getCurrentTenant().toUpperCase());
    }
    return SimpleKeyGenerator.generateKey(initialTenantCreation.toUpperCase(),
        initialTenantCreation.toUpperCase());
  }
}
origin: eclipse/hawkbit

@EventListener(classes = RolloutDeletedEvent.class)
void invalidateCachedTotalTargetCountOnRolloutDelete(final RolloutDeletedEvent event) {
  final Cache cache = tenantAware.runAsTenant(event.getTenant(), () -> cacheManager.getCache(CACHE_RO_NAME));
  cache.evict(event.getEntityId());
}
org.eclipse.hawkbit.tenancyTenantAware

Javadoc

Interface for components that are aware of the application's current tenant.

Most used methods

  • getCurrentTenant
    Implementation might retrieve the current tenant from a session or thread-local.
  • runAsTenant
    Gives the possibility to run a certain code under a specific given tenant. Only the given TenantRunn

Popular in Java

  • Finding current android device location
  • onCreateOptionsMenu (Activity)
  • getApplicationContext (Context)
  • putExtra (Intent)
  • ObjectMapper (com.fasterxml.jackson.databind)
    This mapper (or, data binder, or codec) provides functionality for converting between Java objects (
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • FileInputStream (java.io)
    A FileInputStream obtains input bytes from a file in a file system. What files are available depends
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • ConcurrentHashMap (java.util.concurrent)
    A hash table supporting full concurrency of retrievals and adjustable expected concurrency for updat
  • JFrame (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now