
com.sap.cloud.sdk.cloudplatform.tenant.ScpNeoTenantFacade Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tenant-scp-neo Show documentation
Show all versions of tenant-scp-neo Show documentation
Implementation of the Cloud platform abstraction for tenant functionality
on the SAP Cloud Platform (Neo).
The newest version!
/*
* Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved.
*/
package com.sap.cloud.sdk.cloudplatform.tenant;
import java.util.Optional;
import javax.annotation.Nonnull;
import com.sap.cloud.sdk.cloudplatform.WithRuntimeDependencies;
import com.sap.cloud.sdk.cloudplatform.exception.DependencyNotFoundException;
import com.sap.cloud.sdk.cloudplatform.tenant.exception.TenantAccessException;
/**
* Facade providing access to tenant information on SAP Cloud Platform Neo.
*/
public class ScpNeoTenantFacade extends AbstractTenantFacade implements WithRuntimeDependencies
{
/**
* {@inheritDoc}
*/
@Nonnull
@Override
public Class getTenantClass()
{
return ScpNeoTenant.class;
}
/**
* {@inheritDoc}
*/
@Nonnull
@Override
protected Tenant newMockedTenant()
{
return ScpNeoTenant.ofMockedTenant();
}
/**
* {@inheritDoc}
*/
@Override
public void assertRuntimeDependenciesExist()
throws DependencyNotFoundException
{
try {
Class.forName("com.sap.cloud.account.TenantContext");
}
catch( final ClassNotFoundException e ) {
throw new DependencyNotFoundException(
"Failed to instantiate TenantContext. "
+ "Please make sure to use the local SAP Cloud Platform Neo runtime. "
+ "If you require another container for local deployment, "
+ "make sure to add the latest version of one of the following dependencies to your project: "
+ "'com.sap.cloud:neo-java-web-api' for a Tomcat container or "
+ "'com.sap.cloud:neo-javaee7-wp-api' for a Java EE container such as TomEE. "
+ "Note that this requires separate Maven profiles: "
+ "a profile for local development that uses the respective dependency with scope 'compile' and "
+ "a profile for deployment on SAP Cloud Platform Neo that uses scope 'provided'.",
e);
}
}
/**
* {@inheritDoc}
*/
@Nonnull
@Override
public Optional resolveCurrentTenant()
throws TenantAccessException
{
assertRuntimeDependenciesExist();
final Optional mockedTenant = getMockedTenant();
if( mockedTenant.isPresent() ) {
return mockedTenant;
}
return Optional.of(ScpNeoTenant.ofCurrentTenant());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy