Package org.apache.ofbiz.service
Class ModelService
- All Implemented Interfaces:
Serializable
,Map<String,
Object>
Generic Service Model Class
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,
V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addParam
(ModelParam param) Adds a parameter definition to this service; puts on list in order added then sorts by order if specified.void
addParamClone
(ModelParam param) Adds a clone of a parameter definition to this serviceboolean
Contains permissions boolean.Debug info string.entrySet()
void
evalNotifications
(DispatchContext dctx, Map<String, ? extends Object> context, Map<String, Object> result) Evaluates notificationsevalPermission
(DispatchContext dctx, Map<String, ? extends Object> context) Evaluates permission-service for this service.evalPermissions
(DispatchContext dctx, Map<String, ? extends Object> context) Evaluates permissions for a service.Gets action.Gets all param names.Gets context info.Gets context param list.Gets default entity name.int
Gets defined in count.int
only returns number of defined parameters (not internal)Gets definition location.Gets deprecated reason.Gets deprecated since.Gets deprecated use instead.Gets description.Gets engine name.Gets from loader.Gets impl services.Returns a list of ModelParam objects in the order they were defined when the service was created.getInParameterSequence
(Map<String, ? extends Object> source) Gets a list of required IN parameters in sequence.Gets in param names.Creates a map of service IN parameters using Name as key and Type as value.Gets internal group.Gets invoke.Gets location.int
Gets max retry.Gets metrics.Returns a list of ModelParam objects in the order they were defined when the service was created.Gets model permission.getName()
Gets name.Gets name space.Gets notifications.Gets out param names.Creates a map of service OUT parameters using Name as key and Type as value.Gets override parameters.Gets the ModelParam by namegetParameterNames
(String mode, boolean optional) Gets parameter names.getParameterNames
(String mode, boolean optional, boolean internal) Gets the parameter names of the specified mode (IN/OUT).Gets permission groups.Gets semaphore.int
Gets semaphore sleep.int
Gets semaphore wait.int
Gets transaction timeout.javax.wsdl.Types
Gets types.void
Gets wsdl.void
if the service is declare as deprecated, create a log warning with the reasonboolean
Test if we have already inherited our interface parametersvoid
Run the interface update and inherit all interface parametersboolean
isAuth()
Is auth boolean.boolean
isDebug()
Is debug boolean.boolean
isExport()
Is export boolean.boolean
Is hide result in log boolean.boolean
Is inherited parameters boolean.boolean
Is require new transaction boolean.boolean
Is use transaction boolean.boolean
Check a Map against the IN parameter information, uses the validate() method for that Always called with only IN_PARAM, so to be called before the service is called with the passed contextboolean
Is validate boolean.makeValid
(List<ModelParam> modelParams, Map<String, ? extends Object> source, String mode, boolean includeInternal, List<Object> errorMessages, TimeZone timeZone, Locale locale) Creates a new Map based from an existing map with just valid parameters.Creates a new Map based from an existing map with just valid parameters.makeValid
(Map<String, ? extends Object> source, String mode, boolean includeInternal, List<Object> errorMessages) Creates a new Map based from an existing map with just valid parameters.makeValid
(Map<String, ? extends Object> source, String mode, boolean includeInternal, List<Object> errorMessages, Locale locale) Creates a new Map based from an existing map with just valid parameters.makeValid
(Map<String, ? extends Object> source, String mode, boolean includeInternal, List<Object> errorMessages, TimeZone timeZone, Locale locale) Creates a new Map based from an existing map with just valid parameters.void
Sets action.void
setAuth
(boolean auth) Sets auth.void
setContextInfo
(Map<String, ModelParam> contextInfo) Sets context info.void
setContextParamList
(List<ModelParam> contextParamList) Sets context param list.void
setDebug
(boolean debug) Sets debug.void
setDefaultEntityName
(String defaultEntityName) Sets default entity name.void
setDefinitionLocation
(String definitionLocation) Sets definition location.void
setDeprecatedReason
(String deprecatedReason) Sets deprecated reason.void
setDeprecatedSince
(String deprecatedSince) Sets deprecated since.void
setDeprecatedUseInstead
(String deprecatedUseInstead) Sets deprecated use instead.void
setDescription
(String description) Sets description.void
setEngineName
(String engineName) Sets engine name.void
setExport
(boolean export) Sets export.void
setFromLoader
(String fromLoader) Sets from loader.void
setHideResultInLog
(boolean hideResultInLog) Sets hide result in log.void
setImplServices
(Set<ModelServiceIface> implServices) Sets impl services.void
setInheritedParameters
(boolean inheritedParameters) Sets inherited parameters.void
setInternalGroup
(GroupModel internalGroup) Sets internal group.void
Sets invoke.void
setLocation
(String location) Sets location.void
setMaxRetry
(int maxRetry) Sets max retry.void
setMetrics
(Metrics metrics) Sets metrics.void
setModelPermission
(ModelPermission modelPermission) Sets model permission.void
Sets name.void
setNameSpace
(String nameSpace) Sets name space.void
setNotifications
(List<ModelNotification> notifications) Sets notifications.void
setOverrideParameters
(Set<ModelParam> overrideParameters) Sets override parameters.void
setPermissionGroups
(List<ModelPermGroup> permissionGroups) Sets permission groups.void
setRequireNewTransaction
(boolean requireNewTransaction) Sets require new transaction.void
setSemaphore
(String semaphore) Sets semaphore.void
setSemaphoreSleep
(int semaphoreSleep) Sets semaphore sleep.void
setSemaphoreWait
(int semaphoreWait) Sets semaphore wait.void
setTransactionTimeout
(int transactionTimeout) Sets transaction timeout.void
setUseTransaction
(boolean useTransaction) Sets use transaction.void
setValidate
(boolean validate) Sets validate.toString()
To wsdl document.static boolean
typeValidate
(org.apache.ofbiz.service.ModelParam.ModelParamValidator vali, Object testValue) void
updateDefaultValues
(Map<String, Object> context, String mode) Update default values.void
Validates a Map against the IN or OUT parameter information for a given list of modelParam this is used for recursive validation of map and list modelParam in service definitionvoid
Validates a Map against the IN or OUT parameter informationvoid
validate
(Map<String, ModelParam> modelParamMap, Map<String, ?> values, boolean reverse, ModelService model, String mode, Locale locale) Validates a map of name, object types to a map of name, objectsMethods inherited from class java.util.AbstractMap
clear, clone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, putAll, remove, size, values
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
XSD
- See Also:
-
TNS
- See Also:
-
OUT_PARAM
- See Also:
-
IN_PARAM
- See Also:
-
IN_OUT_PARAM
- See Also:
-
RESPONSE_MESSAGE
- See Also:
-
RESPOND_SUCCESS
- See Also:
-
RESPOND_ERROR
- See Also:
-
RESPOND_FAIL
- See Also:
-
ERROR_MESSAGE
- See Also:
-
ERROR_MESSAGE_LIST
- See Also:
-
ERROR_MESSAGE_MAP
- See Also:
-
SUCCESS_MESSAGE
- See Also:
-
SUCCESS_MESSAGE_LIST
- See Also:
-
-
Constructor Details
-
ModelService
public ModelService() -
ModelService
-
-
Method Details
-
setName
Sets name.- Parameters:
name
- the name
-
setDefinitionLocation
Sets definition location.- Parameters:
definitionLocation
- the definition location
-
setDescription
Sets description.- Parameters:
description
- the description
-
setEngineName
Sets engine name.- Parameters:
engineName
- the engine name
-
setNameSpace
Sets name space.- Parameters:
nameSpace
- the name space
-
setAction
Sets action.- Parameters:
action
- the action
-
setLocation
Sets location.- Parameters:
location
- the location
-
setInvoke
Sets invoke.- Parameters:
invoke
- the invoke
-
setDefaultEntityName
Sets default entity name.- Parameters:
defaultEntityName
- the default entity name
-
setFromLoader
Sets from loader.- Parameters:
fromLoader
- the from loader
-
setAuth
public void setAuth(boolean auth) Sets auth.- Parameters:
auth
- the auth
-
setExport
public void setExport(boolean export) Sets export.- Parameters:
export
- the export
-
setDebug
public void setDebug(boolean debug) Sets debug.- Parameters:
debug
- the debug
-
setValidate
public void setValidate(boolean validate) Sets validate.- Parameters:
validate
- the validate
-
setUseTransaction
public void setUseTransaction(boolean useTransaction) Sets use transaction.- Parameters:
useTransaction
- the use transaction
-
setRequireNewTransaction
public void setRequireNewTransaction(boolean requireNewTransaction) Sets require new transaction.- Parameters:
requireNewTransaction
- the require new transaction
-
setTransactionTimeout
public void setTransactionTimeout(int transactionTimeout) Sets transaction timeout.- Parameters:
transactionTimeout
- the transaction timeout
-
setMaxRetry
public void setMaxRetry(int maxRetry) Sets max retry.- Parameters:
maxRetry
- the max retry
-
setModelPermission
Sets model permission.- Parameters:
modelPermission
- the model permission
-
setSemaphore
Sets semaphore.- Parameters:
semaphore
- the semaphore
-
setSemaphoreWait
public void setSemaphoreWait(int semaphoreWait) Sets semaphore wait.- Parameters:
semaphoreWait
- the semaphore wait
-
setSemaphoreSleep
public void setSemaphoreSleep(int semaphoreSleep) Sets semaphore sleep.- Parameters:
semaphoreSleep
- the semaphore sleep
-
setHideResultInLog
public void setHideResultInLog(boolean hideResultInLog) Sets hide result in log.- Parameters:
hideResultInLog
- the hide result in log
-
getDefinitionLocation
Gets definition location.- Returns:
- the definition location
-
setImplServices
Sets impl services.- Parameters:
implServices
- the impl services
-
setOverrideParameters
Sets override parameters.- Parameters:
overrideParameters
- the override parameters
-
setPermissionGroups
Sets permission groups.- Parameters:
permissionGroups
- the permission groups
-
setNotifications
Sets notifications.- Parameters:
notifications
- the notifications
-
setInternalGroup
Sets internal group.- Parameters:
internalGroup
- the internal group
-
setDeprecatedUseInstead
Sets deprecated use instead.- Parameters:
deprecatedUseInstead
- the deprecated use instead
-
setDeprecatedSince
Sets deprecated since.- Parameters:
deprecatedSince
- the deprecated since
-
setDeprecatedReason
Sets deprecated reason.- Parameters:
deprecatedReason
- the deprecated reason
-
setContextInfo
Sets context info.- Parameters:
contextInfo
- the context info
-
setContextParamList
Sets context param list.- Parameters:
contextParamList
- the context param list
-
setInheritedParameters
public void setInheritedParameters(boolean inheritedParameters) Sets inherited parameters.- Parameters:
inheritedParameters
- the inherited parameters
-
setMetrics
Sets metrics.- Parameters:
metrics
- the metrics
-
getDescription
Gets description.- Returns:
- the description
-
getNameSpace
Gets name space.- Returns:
- the name space
-
getAction
Gets action.- Returns:
- the action
-
getDefaultEntityName
Gets default entity name.- Returns:
- the default entity name
-
getFromLoader
Gets from loader.- Returns:
- the from loader
-
isExport
public boolean isExport()Is export boolean.- Returns:
- the boolean
-
getSemaphoreWait
public int getSemaphoreWait()Gets semaphore wait.- Returns:
- the semaphore wait
-
getSemaphoreSleep
public int getSemaphoreSleep()Gets semaphore sleep.- Returns:
- the semaphore sleep
-
getImplServices
Gets impl services.- Returns:
- the impl services
-
getOverrideParameters
Gets override parameters.- Returns:
- the override parameters
-
getPermissionGroups
Gets permission groups.- Returns:
- the permission groups
-
getNotifications
Gets notifications.- Returns:
- the notifications
-
getInternalGroup
Gets internal group.- Returns:
- the internal group
-
getDeprecatedUseInstead
Gets deprecated use instead.- Returns:
- the deprecated use instead
-
getDeprecatedSince
Gets deprecated since.- Returns:
- the deprecated since
-
getDeprecatedReason
Gets deprecated reason.- Returns:
- the deprecated reason
-
getContextInfo
Gets context info.- Returns:
- the context info
-
getContextParamList
Gets context param list.- Returns:
- the context param list
-
isInheritedParameters
public boolean isInheritedParameters()Is inherited parameters boolean.- Returns:
- the boolean
-
getName
Gets name.- Returns:
- the name
-
getInvoke
Gets invoke.- Returns:
- the invoke
-
isHideResultInLog
public boolean isHideResultInLog()Is hide result in log boolean.- Returns:
- the boolean
-
getMetrics
Gets metrics.- Returns:
- the metrics
-
isAuth
public boolean isAuth()Is auth boolean.- Returns:
- the boolean
-
isValidate
public boolean isValidate()Is validate boolean.- Returns:
- the boolean
-
getModelPermission
Gets model permission.- Returns:
- the model permission
-
isUseTransaction
public boolean isUseTransaction()Is use transaction boolean.- Returns:
- the boolean
-
isRequireNewTransaction
public boolean isRequireNewTransaction()Is require new transaction boolean.- Returns:
- the boolean
-
getTransactionTimeout
public int getTransactionTimeout()Gets transaction timeout.- Returns:
- the transaction timeout
-
getMaxRetry
public int getMaxRetry()Gets max retry.- Returns:
- the max retry
-
getEngineName
Gets engine name.- Returns:
- the engine name
-
getLocation
Gets location.- Returns:
- the location
-
isDebug
public boolean isDebug()Is debug boolean.- Returns:
- the boolean
-
getSemaphore
Gets semaphore.- Returns:
- the semaphore
-
get
-
entrySet
-
put
-
toString
- Overrides:
toString
in classAbstractMap<String,
Object>
-
debugInfo
Debug info string.- Returns:
- the string
-
inheritedParameters
public boolean inheritedParameters()Test if we have already inherited our interface parameters- Returns:
- boolean
-
getParam
Gets the ModelParam by name- Parameters:
name
- The name of the parameter to get- Returns:
- ModelParam object with the specified name
-
addParam
Adds a parameter definition to this service; puts on list in order added then sorts by order if specified. -
addParamClone
Adds a clone of a parameter definition to this service -
getAllParamNames
Gets all param names.- Returns:
- the all param names
-
getInParamNames
Gets in param names.- Returns:
- the in param names
-
getInParamNamesMap
Creates a map of service IN parameters using Name as key and Type as value. Skips internal parameters- Returns:
- Map of IN parameters
-
getOutParamNamesMap
Creates a map of service OUT parameters using Name as key and Type as value. Skips internal parameters- Returns:
- Map of OUT parameters
-
getDefinedInCount
public int getDefinedInCount()Gets defined in count.- Returns:
- the defined in count
-
getOutParamNames
Gets out param names.- Returns:
- the out param names
-
getDefinedOutCount
public int getDefinedOutCount()only returns number of defined parameters (not internal) -
updateDefaultValues
Update default values.- Parameters:
context
- the contextmode
- the mode
-
validate
public void validate(Map<String, Object> context, String mode, Locale locale) throws ServiceValidationExceptionValidates a Map against the IN or OUT parameter information- Parameters:
context
- the contextmode
- Test either mode IN or mode OUTlocale
- the actual locale to use- Throws:
ServiceValidationException
-
validate
public void validate(List<ModelParam> modelParamList, Map<String, Object> context, String mode, Locale locale) throws ServiceValidationExceptionValidates a Map against the IN or OUT parameter information for a given list of modelParam this is used for recursive validation of map and list modelParam in service definition- Parameters:
modelParamList
- List of paramList to validatecontext
- the contextmode
- Test either mode IN or mode OUTlocale
- the actual locale to use- Throws:
ServiceValidationException
-
isValid
Check a Map against the IN parameter information, uses the validate() method for that Always called with only IN_PARAM, so to be called before the service is called with the passed context- Parameters:
context
- the passed contextlocale
- the actual locale to use- Returns:
- boolean True is the service called with these IN_PARAM is valid
-
validate
public void validate(Map<String, ModelParam> modelParamMap, Map<String, throws ServiceValidationException?> values, boolean reverse, ModelService model, String mode, Locale locale) Validates a map of name, object types to a map of name, objects- Parameters:
modelParamMap
- The map of name, modelParamvalues
- The map to test its value types.reverse
- Test the maps in reverse.- Throws:
ServiceValidationException
-
typeValidate
public static boolean typeValidate(org.apache.ofbiz.service.ModelParam.ModelParamValidator vali, Object testValue) throws GeneralException - Throws:
GeneralException
-
getParameterNames
Gets the parameter names of the specified mode (IN/OUT). The parameters will be returned in the order specified in the file. Note: IN and OUT will also contains INOUT parameters.- Parameters:
mode
- The mode (IN/OUT)optional
- True if to include optional parametersinternal
- True to include internal parameters- Returns:
- List of parameter names
-
getParameterNames
Gets parameter names.- Parameters:
mode
- the modeoptional
- the optional- Returns:
- the parameter names
-
makeValid
Creates a new Map based from an existing map with just valid parameters. Tries to convert parameters to required type.- Parameters:
source
- The source mapmode
- The mode which to build the new map
-
makeValid
public Map<String,Object> makeValid(Map<String, ? extends Object> source, String mode, boolean includeInternal, List<Object> errorMessages) Creates a new Map based from an existing map with just valid parameters. Tries to convert parameters to required type.- Parameters:
source
- The source mapmode
- The mode which to build the new mapincludeInternal
- When false will exclude internal fields
-
makeValid
public Map<String,Object> makeValid(Map<String, ? extends Object> source, String mode, boolean includeInternal, List<Object> errorMessages, Locale locale) Creates a new Map based from an existing map with just valid parameters. Tries to convert parameters to required type.- Parameters:
source
- The source mapmode
- The mode which to build the new mapincludeInternal
- When false will exclude internal fieldslocale
- Locale to use to do some type conversion
-
makeValid
public Map<String,Object> makeValid(Map<String, ? extends Object> source, String mode, boolean includeInternal, List<Object> errorMessages, TimeZone timeZone, Locale locale) Creates a new Map based from an existing map with just valid parameters. Tries to convert parameters to required type.- Parameters:
source
- The source mapmode
- The mode which to build the new mapincludeInternal
- When false will exclude internal fieldserrorMessages
- List of errorMessagestimeZone
- The TimeZonelocale
- Locale to use to do some type conversion- Returns:
-
makeValid
public Map<String,Object> makeValid(List<ModelParam> modelParams, Map<String, ? extends Object> source, String mode, boolean includeInternal, List<Object> errorMessages, TimeZone timeZone, Locale locale) Creates a new Map based from an existing map with just valid parameters. Tries to convert parameters to required type.- Parameters:
modelParams
- Model parameters to validatesource
- The source mapmode
- The mode which to build the new mapincludeInternal
- When false will exclude internal fieldserrorMessages
- the list of error messagestimeZone
- TimeZone to use to do some type conversionlocale
- Locale to use to do some type conversion
-
containsPermissions
public boolean containsPermissions()Contains permissions boolean.- Returns:
- the boolean
-
evalPermission
public Map<String,Object> evalPermission(DispatchContext dctx, Map<String, ? extends Object> context) Evaluates permission-service for this service.- Parameters:
dctx
- DispatchContext from the invoked servicecontext
- Map containing userLogin and context information- Returns:
- result of permission service invocation
-
evalNotifications
public void evalNotifications(DispatchContext dctx, Map<String, ? extends Object> context, Map<String, Object> result) Evaluates notifications -
evalPermissions
public Map<String,Object> evalPermissions(DispatchContext dctx, Map<String, ? extends Object> context) Evaluates permissions for a service.- Parameters:
dctx
- DispatchContext from the invoked servicecontext
- Map containing userLogin information- Returns:
- Map if all permissions evaluate return success else return the error message list.
-
getInParameterSequence
Gets a list of required IN parameters in sequence.- Returns:
- A list of required IN parameters in the order which they were defined.
-
getModelParamList
Returns a list of ModelParam objects in the order they were defined when the service was created. -
getInModelParamList
Returns a list of ModelParam objects in the order they were defined when the service was created. -
interfaceUpdate
Run the interface update and inherit all interface parameters- Parameters:
dctx
- The DispatchContext to use for service lookups- Throws:
GenericServiceException
-
informIfDeprecated
public void informIfDeprecated()if the service is declare as deprecated, create a log warning with the reason -
toWSDL
To wsdl document.- Parameters:
locationURI
- the location uri- Returns:
- the document
- Throws:
javax.wsdl.WSDLException
- the wsdl exception
-
getWSDL
Gets wsdl.- Parameters:
def
- the deflocationURI
- the location uri- Throws:
javax.wsdl.WSDLException
- the wsdl exception
-
getTypes
Gets types.- Parameters:
document
- the documentdef
- the def- Returns:
- the types
-