Class 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
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • 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 service
      boolean 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 notifications
      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.
      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 name
      java.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 reason
      boolean inheritedParameters()
      Test if we have already inherited our interface parameters
      void interfaceUpdate​(DispatchContext dctx)
      Run the interface update and inherit all interface parameters
      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
      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.
      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 information
      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)
      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
      • 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 Detail

      • module

        public static final java.lang.String module
      • RESPONSE_MESSAGE

        public static final java.lang.String RESPONSE_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_LIST

        public static final java.lang.String SUCCESS_MESSAGE_LIST
        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()
    • Method Detail

      • get

        public java.lang.Object get​(java.lang.Object name)
        Specified by:
        get in interface java.util.Map<java.lang.String,​java.lang.Object>
        Overrides:
        get in class java.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 interface java.util.Map<java.lang.String,​java.lang.Object>
        Specified by:
        entrySet in class java.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 interface java.util.Map<java.lang.String,​java.lang.Object>
        Overrides:
        put in class java.util.AbstractMap<java.lang.String,​java.lang.Object>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.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 context
        mode - Test either mode IN or mode OUT
        locale - 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 context
        locale - 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 types
        test - 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 parameters
        internal - 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 map
        mode - 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 map
        mode - The mode which to build the new map
        includeInternal - 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 map
        mode - The mode which to build the new map
        includeInternal - When false will exclude internal fields
        locale - 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 map
        mode - The mode which to build the new map
        includeInternal - When false will exclude internal fields
        errorMessages - the list of error messages
        timeZone - TimeZone to use to do some type conversion
        locale - 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 service
        context - 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 service
        context - 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.
      • 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)