Package org.wso2.carbon.context
Class PrivilegedCarbonContext
java.lang.Object
org.wso2.carbon.context.CarbonContext
org.wso2.carbon.context.PrivilegedCarbonContext
This CarbonContext provides users the ability to carry out privileged actions such as
switching tenant flows, setting tenant ID etc.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidstatic voidThis will end the tenant flow and restore the previous CarbonContext.Get the accessing organization id.Get the organization id of the organization where the application resides.Get the operation scope validation context.getOSGiService(Class clazz) Deprecated.getOSGiService(Class clazz, Hashtable<String, String> props) Obtain the first OSGi service found for interface or classclazzand propsgetOSGiServices(Class clazz) Deprecated.please usegetOSGiServices(Class, java.util.Hashtable)insteadgetOSGiServices(Class clazz, Hashtable<String, String> props) Obtain the OSGi services found for interface or classclazzand propsorg.wso2.carbon.registry.api.RegistrygetRegistry(RegistryType type) Method to obtain an instance of a registry on this CarbonContext instance.getTenantDomain(boolean resolve) Method to obtain the tenant domain on this CarbonContext instance.intgetTenantId(boolean resolve) Method to obtain the tenant id on this CarbonContext instance.static PrivilegedCarbonContextvoidsetAccessingOrganizationId(String accessingOrganizationId) Set the accessing organization id.voidsetApplicationName(String applicationName) voidsetApplicationResidentOrganizationId(String applicationResidentOrgId) Set the organization id of the organization where the application is resident when the request comes in tenant perspective.voidsetOperationScopeValidationContext(OperationScopeValidationContext operationScopeValidationContext) Set the operation scope validation context.voidsetOrganizationId(String organizationId) Method to set the organization id on this CarbonContext instance.voidsetRegistry(RegistryType type, org.wso2.carbon.registry.api.Registry registry) Method to set an instance of a registry on this CarbonContext instance.voidsetTenantDomain(String tenantDomain) Method to set the tenant domain on this CarbonContext instance.voidsetTenantDomain(String tenantDomain, boolean resolveTenantId) Method to set the tenant domain on this CarbonContext instance.voidsetTenantId(int tenantId) Method to set the tenant id on this CarbonContext instance.voidsetTenantId(int tenantId, boolean resolveTenantDomain) Method to set the tenant id on this CarbonContext instance.voidMethod to set the user id on this CarbonContext instance.voidsetUsername(String username) Method to set the username on this CarbonContext instance.voidsetUserRealm(org.wso2.carbon.user.api.UserRealm userRealm) voidsetUserResidentOrganizationId(String userResidentOrganizationId) Method to set the user resident organization ID on this CarbonContext instance.static voidStarts a tenant flow.static voidunloadTenant(int tenantId) Methods inherited from class org.wso2.carbon.context.CarbonContext
createFilter, discover, getApplicationName, getCarbonContextDataHolder, getJNDIContext, getJNDIContext, getOrganizationId, getQueue, getTenantDomain, getTenantId, getUserId, getUsername, getUserRealm, getUserResidentOrganizationId
-
Method Details
-
startTenantFlow
public static void startTenantFlow()Starts a tenant flow. This will stack the current CarbonContext and begin a new nested flow which can have an entirely different context. This is ideal for scenarios where multiple super-tenant and sub-tenant phases are required within as a single block of execution.- See Also:
-
endTenantFlow
public static void endTenantFlow()This will end the tenant flow and restore the previous CarbonContext.- See Also:
-
unloadTenant
public static void unloadTenant(int tenantId) -
destroyCurrentContext
public static void destroyCurrentContext() -
getThreadLocalCarbonContext
- Returns:
- PrivilegedCarbonContext from the current thread
-
setTenantId
public void setTenantId(int tenantId) Method to set the tenant id on this CarbonContext instance. This method will not automatically calculate the tenant domain based on the tenant id.- Parameters:
tenantId- the tenant id.
-
setTenantId
public void setTenantId(int tenantId, boolean resolveTenantDomain) Method to set the tenant id on this CarbonContext instance.- Parameters:
tenantId- the tenant id.resolveTenantDomain- whether the tenant domain should be calculated based on this tenant id.
-
setUsername
Method to set the username on this CarbonContext instance.- Parameters:
username- the username.
-
setUserId
Method to set the user id on this CarbonContext instance.- Parameters:
userId- the user id.
-
setOrganizationId
Method to set the organization id on this CarbonContext instance.- Parameters:
organizationId- the organization id.
-
setUserResidentOrganizationId
Method to set the user resident organization ID on this CarbonContext instance.- Parameters:
userResidentOrganizationId- The user's resident organization ID.
-
setTenantDomain
Method to set the tenant domain on this CarbonContext instance. This method will not automatically calculate the tenant id based on the tenant domain.- Parameters:
tenantDomain- the tenant domain.
-
setTenantDomain
Method to set the tenant domain on this CarbonContext instance.- Parameters:
tenantDomain- the tenant domain.resolveTenantId- whether the tenant id should be calculated based on this tenant domain.
-
getTenantDomain
Method to obtain the tenant domain on this CarbonContext instance. This method can optionally resolve the tenant domain using the tenant id that is already posses.- Parameters:
resolve- whether the tenant domain should be calculated based on the tenant id that is already known.- Returns:
- the tenant domain.
-
getTenantId
public int getTenantId(boolean resolve) Method to obtain the tenant id on this CarbonContext instance. This method can optionally resolve the tenant id using the tenant domain that is already posses.- Parameters:
resolve- whether the tenant id should be calculated based on the tenant domain that is already known.- Returns:
- the tenant id.
-
setRegistry
Method to set an instance of a registry on this CarbonContext instance.- Parameters:
type- the type of registry to set.registry- the registry instance.
-
getRegistry
Method to obtain an instance of a registry on this CarbonContext instance.- Overrides:
getRegistryin classCarbonContext- Parameters:
type- the type of registry required.- Returns:
- the requested registry instance.
-
setUserRealm
public void setUserRealm(org.wso2.carbon.user.api.UserRealm userRealm) -
getOSGiService
Deprecated.please usegetOSGiService(Class, java.util.Hashtable)insteadObtain the first OSGi service found for interface or classclazz- Overrides:
getOSGiServicein classCarbonContext- Parameters:
clazz- The type of the OSGi service- Returns:
- The OSGi service
-
getOSGiServices
Deprecated.please usegetOSGiServices(Class, java.util.Hashtable)insteadObtain the OSGi services found for interface or classclazz- Overrides:
getOSGiServicesin classCarbonContext- Parameters:
clazz- The type of the OSGi service- Returns:
- The List of OSGi services
-
getOSGiService
Obtain the first OSGi service found for interface or classclazzand props- Overrides:
getOSGiServicein classCarbonContext- Parameters:
clazz- The type of the OSGi serviceprops- attribute list that filter the service- Returns:
- The OSGi service
-
getOSGiServices
Obtain the OSGi services found for interface or classclazzand props- Overrides:
getOSGiServicesin classCarbonContext- Parameters:
clazz- The type of the OSGi serviceprops- attribute list that filter the service list- Returns:
- The List of OSGi services
-
setApplicationName
-
setApplicationResidentOrganizationId
Set the organization id of the organization where the application is resident when the request comes in tenant perspective.- Parameters:
applicationResidentOrgId- Organization id of the organization where the application is resident.
-
getApplicationResidentOrganizationId
Get the organization id of the organization where the application resides. This will be set when the request comes in tenant perspective.- Returns:
- Organization id of the organization where the application resides.
-
setOperationScopeValidationContext
public void setOperationScopeValidationContext(OperationScopeValidationContext operationScopeValidationContext) Set the operation scope validation context.- Parameters:
operationScopeValidationContext- Operation scope validation context.
-
getOperationScopeValidationContext
Get the operation scope validation context.- Returns:
- Operation scope validation context.
-
setAccessingOrganizationId
Set the accessing organization id.- Parameters:
accessingOrganizationId- Accessing organization id.
-
getAccessingOrganizationId
Get the accessing organization id. This represents the organization id of the accessing organization of the current request.- Returns:
- Accessing organization id.
-
getOSGiService(Class, java.util.Hashtable)instead