All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sap.cloud.mt.runtime.TenantProvider Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 *   © 2019-2024 SAP SE or an SAP affiliate company. All rights reserved.
 ******************************************************************************/
package com.sap.cloud.mt.runtime;


import com.sap.cloud.mt.subscription.exceptions.MtLibError;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.function.Supplier;

public class TenantProvider implements Supplier {
	private static Logger logger = LoggerFactory.getLogger(TenantProvider.class);
	private final IdentityZoneDeterminer determiner;

	public TenantProvider(IdentityZoneDeterminer determiner) {
		this.determiner = determiner;
	}

	@Override
	public String get() {
		try {
			if (TenantOverwrite.isOverwritten()) {
				logger.debug("Tenant overwrite is active");
				return TenantOverwrite.getTenantId();
			}
			String tenantId = determiner.getIdentityZone();
			logger.debug("Tenant id {} determined", tenantId);
			return tenantId;
		} catch (InternalError e) {
			logger.error("Could not determine tenant ID");
			throw new MtLibError(e);
		}
	}
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy