Package com.appiancorp.services
Class AbstractServiceContext
java.lang.Object
com.appiancorp.services.AbstractServiceContext
- All Implemented Interfaces:
com.appiancorp.asl3.servicefw.connect.ServiceContext,com.appiancorp.security.auth.SecurityContext,com.appiancorp.services.AuthorizationInterceptorProvider,KougarServiceContext,ServiceContext,Principal
- Direct Known Subclasses:
UserServiceContext,WebServiceContext
public abstract class AbstractServiceContext
extends Object
implements KougarServiceContext, com.appiancorp.security.auth.SecurityContext, com.appiancorp.services.AuthorizationInterceptorProvider
Represents a service context for use with the service framework. This class
defines the common methods that all service contexts would otherwise have to
implement, but that don't vary much from service context to service context.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedAbstractServiceContext(ServiceContext sc, String grantorUsername) protectedAbstractServiceContext(String username, String grantorUsername) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddService(String serviceName, Object service) Adds the specifiedServiceto the service cache under theserviceName_key specified.applyCaching(com.appiancorp.services.EngineRequestWithCacheToken requestWithCacheToken, Callable<Object> resultProducer) Service an engine request while applying the k call cache if one is enabled.voidClears the call cache of results, if one is enabled and in use.com.appiancorp.security.auth.AppianLoginContextcom.appiancorp.core.expr.portable.common.SessiongetAttribute(String key) Gets the attribute at the specified key.org.aopalliance.intercept.MethodInterceptorgetAuthorizationInterceptor(String actionTargetName, Class<?> targetInterface) com.appiancorp.security.authz.AuthorizationProviderGets the calendar ID, which is used to calculate date in that calendar.longReturns an estimate of the total microseconds saved by using cached call results..intReturns a count of the total number of call cache hits..intReturns a count of the total number of call cache misses..longReturns the total microseconds spent making of K calls..com.appian.komodo.api.EngineCredentialsgetEngineCredentials(com.appiancorp.kougar.services.ServiceConnection svcConn) Returns the credentials to be used for calls with the specifiedKougarConnection.Gets the locale, which affects which language the database will return for multilingual strings.Set<com.appiancorp.type.refs.GroupRef>getName()Returns the username of the user represented by this context.Necessary since this class implementsSecurityContext.intReturns a count of the total number of read K calls..getRoles()getService(String serviceName) RetrievesServicespecified by the given service name from cache.Gets the timezone, which the database uses for time conversions to and from GMT.intReturns a count of the total number of K calls..com.appiancorp.type.refs.UserRefintReturns a count of the total number of write K calls..booleanbooleanbooleanbooleanReturns if call caching is enabled..booleanbooleanisRtl()booleanbooleanremoveAttribute(String key) Removes the attribute at the specified key from the attribute map.voidremoveService(String serviceName) Removes the specified service from the service cache.voidRequest that this service context cache read calls, if supported.voidsetAttribute(String key, Object o) Sets the attribute at the specified key to the specified value.voidsetAuthorizationProvider(com.appiancorp.security.authz.AuthorizationProvider authzProvider) voidsetCalendarID(String calendarID) Sets the ID of the calendar, which is used to calculate date in that calendar.voidSets the locale, which affects which language the database will return for multilingual strings.voidsetTimeZone(TimeZone timeZone) Sets the timezone, which the database uses for time conversions to and from GMT.toString()voidupdateMetrics(com.appiancorp.kougar.services.EngineRequestTelemetry telemetry) Update the K call cache metrics with the timings in the provided telemetry.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.appiancorp.services.ServiceContext
getIdentity, isDesignatedForMigration
-
Field Details
-
PER_EVAL_K_CALL_CACHING_ENABLED
- See Also:
-
PER_EVAL_K_CALL_CACHING_CANARIES_ENABLED
- See Also:
-
-
Constructor Details
-
AbstractServiceContext
protected AbstractServiceContext() -
AbstractServiceContext
-
AbstractServiceContext
-
-
Method Details
-
getAuthorizationProvider
public com.appiancorp.security.authz.AuthorizationProvider getAuthorizationProvider() -
setAuthorizationProvider
public void setAuthorizationProvider(com.appiancorp.security.authz.AuthorizationProvider authzProvider) -
getAuthorizationInterceptor
public org.aopalliance.intercept.MethodInterceptor getAuthorizationInterceptor(String actionTargetName, Class<?> targetInterface) - Specified by:
getAuthorizationInterceptorin interfacecom.appiancorp.services.AuthorizationInterceptorProvider
-
getName
Description copied from interface:ServiceContextReturns the username of the user represented by this context.- Specified by:
getNamein interfacePrincipal- Specified by:
getNamein interfaceServiceContext- Returns:
- the username for this context
-
getUserRef
public com.appiancorp.type.refs.UserRef getUserRef()- Specified by:
getUserRefin interfacecom.appiancorp.security.auth.SecurityContext
-
isUserRefNull
public boolean isUserRefNull()- Specified by:
isUserRefNullin interfacecom.appiancorp.security.auth.SecurityContext
-
getUserUuid
- Specified by:
getUserUuidin interfacecom.appiancorp.security.auth.SecurityContext
-
getMemberGroupUuids
- Specified by:
getMemberGroupUuidsin interfacecom.appiancorp.security.auth.SecurityContext
-
getMemberGroupRefs
- Specified by:
getMemberGroupRefsin interfacecom.appiancorp.security.auth.SecurityContext
-
getRoles
- Specified by:
getRolesin interfacecom.appiancorp.security.auth.SecurityContext
-
isAuthenticatedByAppianInternalProvider
public boolean isAuthenticatedByAppianInternalProvider()- Specified by:
isAuthenticatedByAppianInternalProviderin interfacecom.appiancorp.security.auth.SecurityContext
-
isLoggedInThroughSaml
public boolean isLoggedInThroughSaml()- Specified by:
isLoggedInThroughSamlin interfacecom.appiancorp.security.auth.SecurityContext
-
getAppianLoginContext
public com.appiancorp.security.auth.AppianLoginContext getAppianLoginContext()- Specified by:
getAppianLoginContextin interfacecom.appiancorp.security.auth.SecurityContext
-
isSysAdmin
public boolean isSysAdmin()- Specified by:
isSysAdminin interfacecom.appiancorp.security.auth.SecurityContext
-
getGrantorName
- Specified by:
getGrantorNamein interfacecom.appiancorp.security.auth.SecurityContext
-
getGrantorRoles
- Specified by:
getGrantorRolesin interfacecom.appiancorp.security.auth.SecurityContext
-
addService
Description copied from interface:ServiceContextAdds the specifiedServiceto the service cache under theserviceName_key specified. If the key already exists, then it is overwritten with the new value.- Specified by:
addServicein interfacecom.appiancorp.asl3.servicefw.connect.ServiceContext- Specified by:
addServicein interfaceServiceContext- Parameters:
serviceName- the name of the serviceservice- the service- See Also:
-
getService
Description copied from interface:ServiceContextRetrievesServicespecified by the given service name from cache.- Specified by:
getServicein interfacecom.appiancorp.asl3.servicefw.connect.ServiceContext- Specified by:
getServicein interfaceServiceContext- Parameters:
serviceName- the service name- Returns:
- the service
- See Also:
-
removeService
Description copied from interface:ServiceContextRemoves the specified service from the service cache.- Specified by:
removeServicein interfacecom.appiancorp.asl3.servicefw.connect.ServiceContext- Specified by:
removeServicein interfaceServiceContext- Parameters:
serviceName- the name of the service- See Also:
-
setAttribute
Description copied from interface:ServiceContextSets the attribute at the specified key to the specified value.- Specified by:
setAttributein interfacecom.appiancorp.asl3.servicefw.connect.ServiceContext- Specified by:
setAttributein interfaceServiceContext- Parameters:
key- the keyo- the value- See Also:
-
getAttribute
Description copied from interface:ServiceContextGets the attribute at the specified key.- Specified by:
getAttributein interfacecom.appiancorp.asl3.servicefw.connect.ServiceContext- Specified by:
getAttributein interfaceServiceContext- Parameters:
key- the key- Returns:
- the attribute value
- See Also:
-
removeAttribute
Description copied from interface:ServiceContextRemoves the attribute at the specified key from the attribute map.- Specified by:
removeAttributein interfacecom.appiancorp.asl3.servicefw.connect.ServiceContext- Specified by:
removeAttributein interfaceServiceContext- Parameters:
key- the key- Returns:
- the attribute value before it was removed
- See Also:
-
getLocale
Description copied from interface:ServiceContextGets the locale, which affects which language the database will return for multilingual strings.- Specified by:
getLocalein interfacecom.appiancorp.asl3.servicefw.connect.ServiceContext- Specified by:
getLocalein interfaceServiceContext- Returns:
- the locale
- See Also:
-
setLocale
Description copied from interface:ServiceContextSets the locale, which affects which language the database will return for multilingual strings.- Specified by:
setLocalein interfacecom.appiancorp.asl3.servicefw.connect.ServiceContext- Specified by:
setLocalein interfaceServiceContext- Parameters:
locale- the locale- See Also:
-
isRtl
public boolean isRtl()- Specified by:
isRtlin interfaceServiceContext
-
getOverrideLocale
Necessary since this class implementsSecurityContext. In this case, since this is derived from the originalSecurityContext, just return the same locale asgetLocale()- Specified by:
getOverrideLocalein interfacecom.appiancorp.security.auth.SecurityContext- Returns:
- the locale already stored in this class derived from the original
SecurityContext
-
isAllowOverrideForDisabledLocale
public boolean isAllowOverrideForDisabledLocale()- Specified by:
isAllowOverrideForDisabledLocalein interfacecom.appiancorp.security.auth.SecurityContext
-
isAdsSuperUser
public boolean isAdsSuperUser()- Specified by:
isAdsSuperUserin interfacecom.appiancorp.security.auth.SecurityContext
-
getTimeZone
Description copied from interface:ServiceContextGets the timezone, which the database uses for time conversions to and from GMT.- Specified by:
getTimeZonein interfacecom.appiancorp.asl3.servicefw.connect.ServiceContext- Specified by:
getTimeZonein interfaceServiceContext- Returns:
- the timezone
- See Also:
-
setTimeZone
Description copied from interface:ServiceContextSets the timezone, which the database uses for time conversions to and from GMT.- Specified by:
setTimeZonein interfacecom.appiancorp.asl3.servicefw.connect.ServiceContext- Specified by:
setTimeZonein interfaceServiceContext- Parameters:
timeZone- the timezone- See Also:
-
getCalendarID
Description copied from interface:ServiceContextGets the calendar ID, which is used to calculate date in that calendar.- Specified by:
getCalendarIDin interfaceServiceContext- Returns:
- the Calendar ID
- See Also:
-
#setCalendar(String)
-
setCalendarID
Description copied from interface:ServiceContextSets the ID of the calendar, which is used to calculate date in that calendar.- Specified by:
setCalendarIDin interfaceServiceContext- See Also:
-
#getCalendar()
-
getEngineCredentials
public com.appian.komodo.api.EngineCredentials getEngineCredentials(com.appiancorp.kougar.services.ServiceConnection svcConn) Returns the credentials to be used for calls with the specifiedKougarConnection. The connection may be configured to pass full credentials, or not.- Specified by:
getEngineCredentialsin interfaceKougarServiceContext- Parameters:
svcConn- the connection for which we need the credentials- Returns:
- an
Objectrepresenting the credentials.
-
requestCallCaching
public void requestCallCaching()Request that this service context cache read calls, if supported. Note that this will make the context unsuitable for reuse across different user and security contexts.- Specified by:
requestCallCachingin interfaceServiceContext
-
clearCallCache
public void clearCallCache()Clears the call cache of results, if one is enabled and in use.- Specified by:
clearCallCachein interfaceServiceContext
-
isCallCachingEnabled
public boolean isCallCachingEnabled()Returns if call caching is enabled..- Specified by:
isCallCachingEnabledin interfaceServiceContext- Returns:
- if call caching is enabled.
-
getCallCacheHits
public int getCallCacheHits()Returns a count of the total number of call cache hits..- Specified by:
getCallCacheHitsin interfaceServiceContext- Returns:
- a count of the total number of call cache hits.
-
getCallCacheMisses
public int getCallCacheMisses()Returns a count of the total number of call cache misses..- Specified by:
getCallCacheMissesin interfaceServiceContext- Returns:
- a count of the total number of call cache misses.
-
getCallCacheEstimatedMicrosSaved
public long getCallCacheEstimatedMicrosSaved()Returns an estimate of the total microseconds saved by using cached call results..- Specified by:
getCallCacheEstimatedMicrosSavedin interfaceServiceContext- Returns:
- an estimate of the total microseconds saved by using cached call results.
-
getTotalCallCount
public int getTotalCallCount()Returns a count of the total number of K calls..- Specified by:
getTotalCallCountin interfaceServiceContext- Returns:
- a count of the total number of K calls.
-
getReadCallCount
public int getReadCallCount()Returns a count of the total number of read K calls..- Specified by:
getReadCallCountin interfaceServiceContext- Returns:
- a count of the total number of read K calls.
-
getWriteCallCount
public int getWriteCallCount()Returns a count of the total number of write K calls..- Specified by:
getWriteCallCountin interfaceServiceContext- Returns:
- a count of the total number of write K calls.
-
getCallDurationMicros
public long getCallDurationMicros()Returns the total microseconds spent making of K calls..- Specified by:
getCallDurationMicrosin interfaceServiceContext- Returns:
- the total microseconds spent making of K calls.
-
applyCaching
public Object applyCaching(com.appiancorp.services.EngineRequestWithCacheToken requestWithCacheToken, Callable<Object> resultProducer) throws Exception Service an engine request while applying the k call cache if one is enabled.- Specified by:
applyCachingin interfaceKougarServiceContext- Parameters:
requestWithCacheToken- the request being servicedresultProducer- callback that gets the result from the actual engine- Returns:
- the result of the engine request, which may be a cached value.
- Throws:
Exception
-
updateMetrics
public void updateMetrics(com.appiancorp.kougar.services.EngineRequestTelemetry telemetry) Update the K call cache metrics with the timings in the provided telemetry.- Specified by:
updateMetricsin interfaceKougarServiceContext- Parameters:
telemetry- the metrics for a single executed K call
-
getAppianSession
public com.appiancorp.core.expr.portable.common.Session getAppianSession() -
toString
-