Package org.apache.ofbiz.service
Class ModelService
- java.lang.Object
-
- java.util.AbstractMap<java.lang.String,java.lang.Object>
-
- org.apache.ofbiz.service.ModelService
-
- All Implemented Interfaces:
java.io.Serializable
,java.util.Map<java.lang.String,java.lang.Object>
public class ModelService extends java.util.AbstractMap<java.lang.String,java.lang.Object> implements java.io.Serializable
Generic Service Model Class- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description boolean
auth
Does this service require authorizationprotected java.util.Map<java.lang.String,ModelParam>
contextInfo
Context Information, a Map of parameters used by the service, contains ModelParam objectsprotected java.util.List<ModelParam>
contextParamList
Context Information, a List of parameters used by the service, contains ModelParam objectsboolean
debug
Enable verbose debugging when calling this servicejava.lang.String
defaultEntityName
The default Entity to use for auto-attributesjava.lang.String
definitionLocation
The location of the definition this servicejava.lang.String
deprecatedReason
java.lang.String
deprecatedSince
java.lang.String
deprecatedUseInstead
Deprecated informationjava.lang.String
description
The description of this servicejava.lang.String
engineName
The name of the service enginestatic java.lang.String
ERROR_MESSAGE
static java.lang.String
ERROR_MESSAGE_LIST
static java.lang.String
ERROR_MESSAGE_MAP
boolean
export
Can this service be exported via RPC, RMI, SOAP, etcjava.lang.String
fromLoader
The loader which loaded this definitionboolean
hideResultInLog
Require a new transaction for this servicejava.util.Set<ModelServiceIface>
implServices
Set of services this service implementsstatic java.lang.String
IN_OUT_PARAM
static java.lang.String
IN_PARAM
protected boolean
inheritedParameters
Flag to say if we have pulled in our addition parameters from our implemented service(s)GroupModel
internalGroup
Internal Service Groupjava.lang.String
invoke
The method or function to invoke for this servicejava.lang.String
location
The package name or location of this serviceint
maxRetry
Sets the max number of times this service will retry when failed (persisted async only)Metrics
metrics
Service metrics.static java.lang.String
module
java.lang.String
name
The name of this servicejava.lang.String
nameSpace
The namespace of this servicejava.util.List<ModelNotification>
notifications
List of email-notifications for this servicestatic java.lang.String
OUT_PARAM
java.util.Set<ModelParam>
overrideParameters
Set of override parametersjava.util.List<ModelPermGroup>
permissionGroups
List of permission groups for service invocationjava.lang.String
permissionMainAction
Permission service main-actionjava.lang.String
permissionResourceDesc
Permission service resource-descriptionjava.lang.String
permissionServiceName
Permission service nameboolean
requireNewTransaction
Require a new transaction for this servicestatic java.lang.String
resource
static java.lang.String
RESPOND_ERROR
static java.lang.String
RESPOND_FAIL
static java.lang.String
RESPOND_SUCCESS
static java.lang.String
RESPONSE_MESSAGE
java.lang.String
semaphore
Semaphore setting (wait, fail, none)int
semaphoreSleep
Semaphore sleep time (in milliseconds)int
semaphoreWait
Semaphore wait time (in milliseconds)static java.lang.String
SUCCESS_MESSAGE
static java.lang.String
SUCCESS_MESSAGE_LIST
static java.lang.String
TNS
int
transactionTimeout
Override the default transaction timeout, only works if we start the transactionboolean
useTransaction
Create a transaction for this service (if one is not already in place...)?boolean
validate
Validate the context info for this servicestatic java.lang.String
XSD
-
Constructor Summary
Constructors Constructor Description ModelService()
ModelService(ModelService model)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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
containsPermissions()
java.lang.String
debugInfo()
java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>>
entrySet()
void
evalNotifications(DispatchContext dctx, java.util.Map<java.lang.String,? extends java.lang.Object> context, java.util.Map<java.lang.String,java.lang.Object> result)
Evaluates notificationsjava.util.Map<java.lang.String,java.lang.Object>
evalPermission(DispatchContext dctx, java.util.Map<java.lang.String,? extends java.lang.Object> context)
Evaluates permission-service for this service.boolean
evalPermissions(DispatchContext dctx, java.util.Map<java.lang.String,? extends java.lang.Object> context)
Evaluates permissions for a service.java.lang.Object
get(java.lang.Object name)
java.util.Set<java.lang.String>
getAllParamNames()
int
getDefinedInCount()
int
getDefinedOutCount()
java.util.List<ModelParam>
getInModelParamList()
Returns a list of ModelParam objects in the order they were defined when the service was created.java.util.List<java.lang.Object>
getInParameterSequence(java.util.Map<java.lang.String,? extends java.lang.Object> source)
Gets a list of required IN parameters in sequence.java.util.Set<java.lang.String>
getInParamNames()
java.util.List<ModelParam>
getModelParamList()
Returns a list of ModelParam objects in the order they were defined when the service was created.java.util.Set<java.lang.String>
getOutParamNames()
ModelParam
getParam(java.lang.String name)
Gets the ModelParam by namejava.util.List<java.lang.String>
getParameterNames(java.lang.String mode, boolean optional)
java.util.List<java.lang.String>
getParameterNames(java.lang.String mode, boolean optional, boolean internal)
Gets the parameter names of the specified mode (IN/OUT/INOUT).javax.wsdl.Types
getTypes(org.w3c.dom.Document document, javax.wsdl.Definition def)
void
getWSDL(javax.wsdl.Definition def, java.lang.String locationURI)
void
informIfDeprecated()
if the service is declare as deprecated, create a log warning with the reasonboolean
inheritedParameters()
Test if we have already inherited our interface parametersvoid
interfaceUpdate(DispatchContext dctx)
Run the interface update and inherit all interface parametersboolean
isValid(java.util.Map<java.lang.String,java.lang.Object> context, java.util.Locale locale)
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 contextjava.util.Map<java.lang.String,java.lang.Object>
makeValid(java.util.Map<java.lang.String,? extends java.lang.Object> source, java.lang.String mode)
Creates a new Map based from an existing map with just valid parameters.java.util.Map<java.lang.String,java.lang.Object>
makeValid(java.util.Map<java.lang.String,? extends java.lang.Object> source, java.lang.String mode, boolean includeInternal, java.util.List<java.lang.Object> errorMessages)
Creates a new Map based from an existing map with just valid parameters.java.util.Map<java.lang.String,java.lang.Object>
makeValid(java.util.Map<java.lang.String,? extends java.lang.Object> source, java.lang.String mode, boolean includeInternal, java.util.List<java.lang.Object> errorMessages, java.util.Locale locale)
Creates a new Map based from an existing map with just valid parameters.java.util.Map<java.lang.String,java.lang.Object>
makeValid(java.util.Map<java.lang.String,? extends java.lang.Object> source, java.lang.String mode, boolean includeInternal, java.util.List<java.lang.Object> errorMessages, java.util.TimeZone timeZone, java.util.Locale locale)
Creates a new Map based from an existing map with just valid parameters.java.lang.Object
put(java.lang.String o1, java.lang.Object o2)
java.lang.String
toString()
org.w3c.dom.Document
toWSDL(java.lang.String locationURI)
static boolean
typeValidate(org.apache.ofbiz.service.ModelParam.ModelParamValidator vali, java.lang.Object testValue)
void
updateDefaultValues(java.util.Map<java.lang.String,java.lang.Object> context, java.lang.String mode)
void
validate(java.util.Map<java.lang.String,java.lang.Object> context, java.lang.String mode, java.util.Locale locale)
Validates a Map against the IN or OUT parameter informationstatic void
validate(java.util.Map<java.lang.String,java.lang.String> info, java.util.Map<java.lang.String,? extends java.lang.Object> test, boolean reverse, ModelService model, java.lang.String mode, java.util.Locale locale)
Validates a map of name, object types to a map of name, objects-
Methods inherited from class java.util.AbstractMap
clear, clone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, putAll, remove, size, values
-
-
-
-
Field Detail
-
module
public static final java.lang.String module
-
XSD
public static final java.lang.String XSD
- See Also:
- Constant Field Values
-
TNS
public static final java.lang.String TNS
- See Also:
- Constant Field Values
-
OUT_PARAM
public static final java.lang.String OUT_PARAM
- See Also:
- Constant Field Values
-
IN_PARAM
public static final java.lang.String IN_PARAM
- See Also:
- Constant Field Values
-
IN_OUT_PARAM
public static final java.lang.String IN_OUT_PARAM
- See Also:
- Constant Field Values
-
RESPONSE_MESSAGE
public static final java.lang.String RESPONSE_MESSAGE
- See Also:
- Constant Field Values
-
RESPOND_SUCCESS
public static final java.lang.String RESPOND_SUCCESS
- See Also:
- Constant Field Values
-
RESPOND_ERROR
public static final java.lang.String RESPOND_ERROR
- See Also:
- Constant Field Values
-
RESPOND_FAIL
public static final java.lang.String RESPOND_FAIL
- See Also:
- Constant Field Values
-
ERROR_MESSAGE
public static final java.lang.String ERROR_MESSAGE
- See Also:
- Constant Field Values
-
ERROR_MESSAGE_LIST
public static final java.lang.String ERROR_MESSAGE_LIST
- See Also:
- Constant Field Values
-
ERROR_MESSAGE_MAP
public static final java.lang.String ERROR_MESSAGE_MAP
- See Also:
- Constant Field Values
-
SUCCESS_MESSAGE
public static final java.lang.String SUCCESS_MESSAGE
- See Also:
- Constant Field Values
-
SUCCESS_MESSAGE_LIST
public static final java.lang.String SUCCESS_MESSAGE_LIST
- See Also:
- Constant Field Values
-
resource
public static final java.lang.String resource
- See Also:
- Constant Field Values
-
name
public java.lang.String name
The name of this service
-
definitionLocation
public java.lang.String definitionLocation
The location of the definition this service
-
description
public java.lang.String description
The description of this service
-
engineName
public java.lang.String engineName
The name of the service engine
-
nameSpace
public java.lang.String nameSpace
The namespace of this service
-
location
public java.lang.String location
The package name or location of this service
-
invoke
public java.lang.String invoke
The method or function to invoke for this service
-
defaultEntityName
public java.lang.String defaultEntityName
The default Entity to use for auto-attributes
-
fromLoader
public java.lang.String fromLoader
The loader which loaded this definition
-
auth
public boolean auth
Does this service require authorization
-
export
public boolean export
Can this service be exported via RPC, RMI, SOAP, etc
-
debug
public boolean debug
Enable verbose debugging when calling this service
-
validate
public boolean validate
Validate the context info for this service
-
useTransaction
public boolean useTransaction
Create a transaction for this service (if one is not already in place...)?
-
requireNewTransaction
public boolean requireNewTransaction
Require a new transaction for this service
-
transactionTimeout
public int transactionTimeout
Override the default transaction timeout, only works if we start the transaction
-
maxRetry
public int maxRetry
Sets the max number of times this service will retry when failed (persisted async only)
-
permissionServiceName
public java.lang.String permissionServiceName
Permission service name
-
permissionMainAction
public java.lang.String permissionMainAction
Permission service main-action
-
permissionResourceDesc
public java.lang.String permissionResourceDesc
Permission service resource-description
-
semaphore
public java.lang.String semaphore
Semaphore setting (wait, fail, none)
-
semaphoreWait
public int semaphoreWait
Semaphore wait time (in milliseconds)
-
semaphoreSleep
public int semaphoreSleep
Semaphore sleep time (in milliseconds)
-
hideResultInLog
public boolean hideResultInLog
Require a new transaction for this service
-
implServices
public java.util.Set<ModelServiceIface> implServices
Set of services this service implements
-
overrideParameters
public java.util.Set<ModelParam> overrideParameters
Set of override parameters
-
permissionGroups
public java.util.List<ModelPermGroup> permissionGroups
List of permission groups for service invocation
-
notifications
public java.util.List<ModelNotification> notifications
List of email-notifications for this service
-
internalGroup
public GroupModel internalGroup
Internal Service Group
-
deprecatedUseInstead
public java.lang.String deprecatedUseInstead
Deprecated information
-
deprecatedSince
public java.lang.String deprecatedSince
-
deprecatedReason
public java.lang.String deprecatedReason
-
contextInfo
protected java.util.Map<java.lang.String,ModelParam> contextInfo
Context Information, a Map of parameters used by the service, contains ModelParam objects
-
contextParamList
protected java.util.List<ModelParam> contextParamList
Context Information, a List of parameters used by the service, contains ModelParam objects
-
inheritedParameters
protected boolean inheritedParameters
Flag to say if we have pulled in our addition parameters from our implemented service(s)
-
metrics
public Metrics metrics
Service metrics.
-
-
Constructor Detail
-
ModelService
public ModelService()
-
ModelService
public ModelService(ModelService model)
-
-
Method Detail
-
get
public java.lang.Object get(java.lang.Object name)
- Specified by:
get
in interfacejava.util.Map<java.lang.String,java.lang.Object>
- Overrides:
get
in classjava.util.AbstractMap<java.lang.String,java.lang.Object>
-
entrySet
public java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> entrySet()
- Specified by:
entrySet
in interfacejava.util.Map<java.lang.String,java.lang.Object>
- Specified by:
entrySet
in classjava.util.AbstractMap<java.lang.String,java.lang.Object>
-
put
public java.lang.Object put(java.lang.String o1, java.lang.Object o2)
- Specified by:
put
in interfacejava.util.Map<java.lang.String,java.lang.Object>
- Overrides:
put
in classjava.util.AbstractMap<java.lang.String,java.lang.Object>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.util.AbstractMap<java.lang.String,java.lang.Object>
-
debugInfo
public java.lang.String debugInfo()
-
inheritedParameters
public boolean inheritedParameters()
Test if we have already inherited our interface parameters- Returns:
- boolean
-
getParam
public ModelParam getParam(java.lang.String name)
Gets the ModelParam by name- Parameters:
name
- The name of the parameter to get- Returns:
- ModelParam object with the specified name
-
addParam
public void addParam(ModelParam param)
Adds a parameter definition to this service; puts on list in order added then sorts by order if specified.
-
addParamClone
public void addParamClone(ModelParam param)
Adds a clone of a parameter definition to this service
-
getAllParamNames
public java.util.Set<java.lang.String> getAllParamNames()
-
getInParamNames
public java.util.Set<java.lang.String> getInParamNames()
-
getDefinedInCount
public int getDefinedInCount()
-
getOutParamNames
public java.util.Set<java.lang.String> getOutParamNames()
-
getDefinedOutCount
public int getDefinedOutCount()
-
updateDefaultValues
public void updateDefaultValues(java.util.Map<java.lang.String,java.lang.Object> context, java.lang.String mode)
-
validate
public void validate(java.util.Map<java.lang.String,java.lang.Object> context, java.lang.String mode, java.util.Locale locale) throws ServiceValidationException
Validates 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
-
isValid
public boolean isValid(java.util.Map<java.lang.String,java.lang.Object> context, java.util.Locale locale)
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 static void validate(java.util.Map<java.lang.String,java.lang.String> info, java.util.Map<java.lang.String,? extends java.lang.Object> test, boolean reverse, ModelService model, java.lang.String mode, java.util.Locale locale) throws ServiceValidationException
Validates a map of name, object types to a map of name, objects- Parameters:
info
- The map of name, object typestest
- 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, java.lang.Object testValue) throws GeneralException
- Throws:
GeneralException
-
getParameterNames
public java.util.List<java.lang.String> getParameterNames(java.lang.String mode, boolean optional, boolean internal)
Gets the parameter names of the specified mode (IN/OUT/INOUT). 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/INOUT)optional
- True if to include optional parametersinternal
- True to include internal parameters- Returns:
- List of parameter names
-
getParameterNames
public java.util.List<java.lang.String> getParameterNames(java.lang.String mode, boolean optional)
-
makeValid
public java.util.Map<java.lang.String,java.lang.Object> makeValid(java.util.Map<java.lang.String,? extends java.lang.Object> source, java.lang.String mode)
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 java.util.Map<java.lang.String,java.lang.Object> makeValid(java.util.Map<java.lang.String,? extends java.lang.Object> source, java.lang.String mode, boolean includeInternal, java.util.List<java.lang.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 java.util.Map<java.lang.String,java.lang.Object> makeValid(java.util.Map<java.lang.String,? extends java.lang.Object> source, java.lang.String mode, boolean includeInternal, java.util.List<java.lang.Object> errorMessages, java.util.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 java.util.Map<java.lang.String,java.lang.Object> makeValid(java.util.Map<java.lang.String,? extends java.lang.Object> source, java.lang.String mode, boolean includeInternal, java.util.List<java.lang.Object> errorMessages, java.util.TimeZone timeZone, java.util.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
- 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()
-
evalPermission
public java.util.Map<java.lang.String,java.lang.Object> evalPermission(DispatchContext dctx, java.util.Map<java.lang.String,? extends java.lang.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, java.util.Map<java.lang.String,? extends java.lang.Object> context, java.util.Map<java.lang.String,java.lang.Object> result)
Evaluates notifications
-
evalPermissions
public boolean evalPermissions(DispatchContext dctx, java.util.Map<java.lang.String,? extends java.lang.Object> context)
Evaluates permissions for a service.- Parameters:
dctx
- DispatchContext from the invoked servicecontext
- Map containing userLogin information- Returns:
- true if all permissions evaluate true.
-
getInParameterSequence
public java.util.List<java.lang.Object> getInParameterSequence(java.util.Map<java.lang.String,? extends java.lang.Object> source)
Gets a list of required IN parameters in sequence.- Returns:
- A list of required IN parameters in the order which they were defined.
-
getModelParamList
public java.util.List<ModelParam> getModelParamList()
Returns a list of ModelParam objects in the order they were defined when the service was created.
-
getInModelParamList
public java.util.List<ModelParam> getInModelParamList()
Returns a list of ModelParam objects in the order they were defined when the service was created.
-
interfaceUpdate
public void interfaceUpdate(DispatchContext dctx) throws GenericServiceException
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
public org.w3c.dom.Document toWSDL(java.lang.String locationURI) throws javax.wsdl.WSDLException
- Throws:
javax.wsdl.WSDLException
-
getWSDL
public void getWSDL(javax.wsdl.Definition def, java.lang.String locationURI) throws javax.wsdl.WSDLException
- Throws:
javax.wsdl.WSDLException
-
getTypes
public javax.wsdl.Types getTypes(org.w3c.dom.Document document, javax.wsdl.Definition def)
-
-