Class JSONTool

  • Direct Known Subclasses:
    JSONServletTool

    public class JSONTool
    extends java.lang.Object
    JSON toolbox
    This class only provides static variables and methods
    • Constructor Summary

      Constructors 
      Constructor Description
      JSONTool()
      Hidden default constructor
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static java.lang.String actionToJson​(ObjectDB obj, Action action, java.lang.String[] row, boolean create, int context)  
      static java.lang.String activityData​(Processus pcs, ActivityFile af, ObjectDB object)  
      static java.lang.String activityData​(Processus pcs, ActivityFile af, ObjectDB object, boolean metadata, boolean embedded)  
      static java.lang.String activityDataToJson​(Processus p, ActivityFile af, ObjectDB obj, boolean metadata)  
      static java.lang.String activityMetaDataToJson​(Activity a)  
      static org.json.JSONObject addActionResultSchema​(org.json.JSONObject schemas)
      Add action result OpenAPI schemas description to schemas
      static org.json.JSONObject addAppSessionOpenAPIPath​(org.json.JSONObject paths, int spec)
      Add application and session REST services OpenAPI paths description to paths
      static org.json.JSONObject addBusinessObjectOpenAPIPath​(org.json.JSONObject paths, ObjectDB obj, java.lang.String relPath, int spec)
      Add business object REST services OpenAPI paths to paths
      static org.json.JSONObject addBusinessObjectOpenAPISchema​(org.json.JSONObject schemas, ObjectDB obj, int spec)
      Add business object REST services OpenAPI schema to schemas
      static org.json.JSONObject addErrorsSchema​(org.json.JSONObject schemas)
      Add error messages OpenAPI schemas description to schemas
      static org.json.JSONObject addLoginOpenAPIPath​(org.json.JSONObject paths, int spec)
      Add login service OpenAPI path description to paths
      static org.json.JSONObject addLogoutOpenAPIPath​(org.json.JSONObject paths, int spec)
      Add logout service OpenAPI path description to paths
      static org.json.JSONObject addOpenAPIErrorsSchemas​(org.json.JSONObject schemas, int[] errs, int spec)
      Add OpenAPI errors schemas
      static org.json.JSONObject addOpenAPIOperationType​(org.json.JSONObject operation, java.lang.String requestType, java.lang.String requestSchema, java.lang.String responseType, java.lang.String responseSchema, int[] errorStatuses, int spec)
      Get OpenAPI operation types
      static org.json.JSONObject addOpenAPIOperationTypes​(org.json.JSONObject operation, java.lang.String[] requestTypes, java.lang.String requestSchema, java.lang.String[] responseTypes, java.lang.String responseSchema, int[] errorStatuses, int spec)
      Get OpenAPI operation types
      static org.json.JSONObject addOpenAPIParameterType​(org.json.JSONObject param, java.lang.String type, java.lang.String format, java.lang.String pattern, org.json.JSONArray values, int spec)
      Add OpenAPI parameter type
      static org.json.JSONObject addOpenAPIParameterType​(org.json.JSONObject param, java.lang.String type, org.json.JSONArray values, int spec)
      Add OpenAPI parameter type
      static org.json.JSONObject addPlaceMapSchema​(org.json.JSONObject schemas, int spec)
      Add placemap result OpenAPI schemas description to schemas
      static org.json.JSONObject addPublicationResultSchema​(org.json.JSONObject schemas)
      Add publication result OpenAPI schemas description to schemas
      static org.json.JSONArray addTag​(org.json.JSONArray tags, java.lang.String name, java.lang.String desc)
      Add a tag
      static org.json.JSONObject addTreeviewDataSchema​(org.json.JSONObject schemas)
      Add treeview data OpenAPI schemas description to schemas
      static java.lang.String count​(ObjectDB obj)  
      static java.lang.String count​(ObjectDB obj, boolean metadata)  
      static java.lang.String document​(ObjectDB obj, java.lang.String rowId, java.lang.String field)  
      static java.lang.String document​(ObjectDB obj, java.lang.String rowId, java.lang.String field, boolean embedded, boolean copy)  
      static java.lang.String error​(int status, java.lang.String message, int level, java.lang.String metadata)
      Error response
      static java.lang.String error​(java.lang.String message, int level)
      Error response
      static java.lang.String error​(java.lang.String message, int level, java.lang.String metadata)
      Error response
      static java.lang.String errors​(int status, java.lang.String[] messages, int level, java.lang.String metadata)
      Errors response
      static java.lang.String errors​(java.lang.String[] messages, int level)
      Errors response
      static java.lang.String errors​(java.lang.String[] messages, int level, java.lang.String metadata)
      Errors response
      static java.lang.String fieldsToJson​(ObjectDB obj)  
      static java.lang.String fieldsToJson​(ObjectDB obj, Parameters.InlineParam inlines, java.lang.String[] fields, boolean onlyFunctIds, boolean timestamps)  
      static java.lang.String fieldValue​(ObjectField field)  
      static java.lang.String fieldValue​(ObjectField field, java.lang.String value)  
      static java.lang.String filters​(ObjectDB obj, boolean reset)  
      static java.lang.String filters​(ObjectDB obj, int context, boolean reset)  
      static java.lang.String filters​(ObjectDB obj, int context, boolean reset, boolean embedded)  
      static java.lang.String filtersToJson​(ObjectDB obj, boolean reset, boolean limited)
      JSON filters in service format
      static java.lang.String fromJSONName​(java.lang.String name)
      Get internal name (using dots as separator) from JSON name (using Globals.DOT_REPLACEMENT as separator)
      static org.json.JSONObject fromYAML​(java.lang.String yaml)
      Convert YAML to JSON object (alias to fromYAMLToJSONObject
      static org.json.JSONArray fromYAMLToJSONArray​(java.lang.String yaml)
      Convert YAML to JSON array
      static org.json.JSONObject fromYAMLToJSONObject​(java.lang.String yaml)
      Convert YAML to JSON object
      static java.lang.String functIdToJson​(ObjectDB obj)  
      static java.lang.String get​(ObjectDB obj, java.lang.String rowId)
      Get object record as JSON
      static java.lang.String get​(ObjectDB obj, java.lang.String rowId, boolean embedded)
      Get object record as JSON
      static java.lang.String get​(ObjectDB obj, java.lang.String rowId, int context, boolean timestamps, java.lang.String[] fields, Parameters.InlineParam inlines, boolean embedded, boolean metadata, Parameters.ContextParam parent, boolean social, boolean share, java.util.List<java.lang.String> msgs, TreeView tv, TreeView.TreeViewNode tvNode, int tvDepth)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use get with additional argument
      static java.lang.String get​(ObjectDB obj, java.lang.String rowId, int context, boolean timestamps, java.lang.String[] fields, Parameters.InlineParam inlines, boolean embedded, boolean metadata, Parameters.ContextParam parent, boolean social, java.util.List<java.lang.String> msgs, TreeView tv, TreeView.TreeViewNode tvNode, int tvDepth)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use get with additional argument
      static java.lang.String get​(ObjectDB obj, java.lang.String rowId, int context, boolean timestamps, java.lang.String[] fields, ServletParameters values, Parameters.InlineParam inlines, boolean embedded, boolean metadata, Parameters.ContextParam parent, boolean social, boolean share, java.util.List<java.lang.String> msgs, Parameters.TreeviewParam tv)
      Get object record as JSON
      static java.lang.String get​(ObjectDB obj, java.lang.String rowId, int context, java.lang.String[] fields, Parameters.InlineParam inlines, boolean embedded)
      Get object record as JSON
      static java.lang.String getCompactName​(Grant g)  
      static org.json.JSONObject getError​(int status, java.lang.Object message, int level, org.json.JSONObject metadata)
      Get error response
      static org.json.JSONObject getError​(java.lang.Object message, int level)
      Get error response
      static org.json.JSONObject getError​(java.lang.Object message, int level, org.json.JSONObject metadata)
      Get error response
      static org.json.JSONObject getErrors​(int status, java.lang.Object messages, int level, org.json.JSONObject metadata)
      Get errors response
      static org.json.JSONObject getErrors​(java.lang.Object messages, int level)
      Get errors response
      static org.json.JSONObject getErrors​(java.lang.Object messages, int level, org.json.JSONObject metadata)
      Get errors response
      static java.lang.String getHistoryName​(Grant g)  
      static org.json.JSONObject getInfo​(java.lang.String message)
      Get info response
      static java.lang.String getJSONASCIILogo​(java.lang.String complement)
      Get ASCII logo as JSON comments
      static org.json.JSONObject getJSONObjectFromXML​(java.lang.String xml)
      Get JSON object from XML
      static org.json.JSONObject getJSONSchema​(ObjectDB obj)
      Get JSON Schema for specified object
      static org.json.JSONObject getOpenAPIError​(int code, int spec)
      Get OpenAPI error
      static org.json.JSONObject getOpenAPIInfo​(java.lang.String title, java.lang.String desc, java.lang.String version, boolean license, boolean contact)
      Get OpenAPI info
      static java.lang.String getOpenAPIRef​(java.lang.String name, int spec)
      Get OpenAPI reference
      static org.json.JSONObject getOpenAPISchema​(Grant g, int spec, org.json.JSONObject info, org.json.JSONArray tags, java.lang.String basePath, org.json.JSONObject paths, org.json.JSONObject schemas)
      Deprecated.
      Use getOpenAPISchema with security argument
      static org.json.JSONObject getOpenAPISchema​(Grant g, int spec, org.json.JSONObject info, org.json.JSONArray tags, java.lang.String basePath, org.json.JSONObject paths, org.json.JSONObject schemas, boolean security)
      Get OpenAPI schema
      static java.lang.String getProcessExternalContent​(Processus p, ActivityFile context, ObjectContextWeb ctx)
      Prepare content of external activity (Page.Method)
      static org.json.JSONObject getResponse​(java.lang.String type, java.lang.Object response)
      Get response JSON object
      static org.json.JSONObject getResponse​(java.lang.String type, java.lang.Object response, java.lang.String msg)
      Get response JSON object
      static org.json.JSONObject getSysParam​(Grant g, java.lang.String name)
      Get a single session system parameter as JSON
      static org.json.JSONObject getSysParam​(Grant g, java.lang.String name, boolean force)
      Get a single system parameter as JSON
      static org.json.JSONObject getSysParams​(Grant g, boolean embedded)
      Get all session system parameters as JSON oject
      static java.lang.String getTexts​(Grant g)
      Deprecated.
      Use Grant.toJSONTexts
      static java.lang.String getTexts​(Grant g, java.lang.String regex)
      Deprecated.
      Use Grant.toJSONTexts
      static org.json.JSONObject getWarning​(java.lang.String message)
      Get warning response
      static org.json.JSONObject getWarnings​(java.lang.String[] messages)
      Get warnings response
      static java.lang.String getXMLFromJSONObject​(org.json.JSONObject json)
      Get XML from JSON objectL
      static java.lang.String getYAMLASCIILogo​(java.lang.String complement)
      Get ASCII logo as YAML comments
      static org.yaml.snakeyaml.Yaml getYAMLProcessor()
      Get YAML processor
      static java.lang.String getZoomName​(Grant g)  
      static java.lang.String groupByToJson​(ObjectDB obj, java.util.List<java.lang.String[]> list)  
      static java.lang.String historic​(ObjectDB obj, int page)  
      static java.lang.String indexMetaDataToJson​(Grant g)
      Index metadata as JSON string
      static java.lang.String info​(java.lang.String message)  
      static ObjectContextWeb initWebService​(ObjectDB obj, int context, Parameters.ContextParam p, boolean apply, java.lang.String edit)
      Prepare the object context for web service
      static java.lang.String jsonAppInfo​(Grant g, boolean embedded)
      Application info as JSON string
      static java.lang.String jsonArray​(double[] vals)
      Get JSON array from doubles array
      static java.lang.String jsonArray​(java.lang.Double[] vals)
      Get JSON array from Doubles array
      static java.lang.String jsonArray​(java.lang.Object[] contents)
      Get JSON array from objects array
      static java.lang.String jsonArray​(java.util.List<?> contents)
      Get JSON array from object list
      static java.lang.String jsonDeclaration​(ObjectField f)  
      static java.lang.String jsonDeclaration​(ObjectField f, java.lang.Object value)  
      static java.lang.String jsonDeclaration​(java.lang.String name, boolean content)  
      static java.lang.String jsonDeclaration​(java.lang.String name, double content)  
      static java.lang.String jsonDeclaration​(java.lang.String name, double[] contents)  
      static java.lang.String jsonDeclaration​(java.lang.String name, float content)  
      static java.lang.String jsonDeclaration​(java.lang.String name, float[] contents)  
      static java.lang.String jsonDeclaration​(java.lang.String name, int content)  
      static java.lang.String jsonDeclaration​(java.lang.String name, int[] contents)  
      static java.lang.String jsonDeclaration​(java.lang.String name, long content)  
      static java.lang.String jsonDeclaration​(java.lang.String name, long[] contents)  
      static java.lang.String jsonDeclaration​(java.lang.String name, java.lang.Boolean content)  
      static java.lang.String jsonDeclaration​(java.lang.String name, java.lang.Double content)  
      static java.lang.String jsonDeclaration​(java.lang.String name, java.lang.Float content)  
      static java.lang.String jsonDeclaration​(java.lang.String name, java.lang.Integer content)  
      static java.lang.String jsonDeclaration​(java.lang.String name, java.lang.Long content)  
      static java.lang.String jsonDeclaration​(java.lang.String name, java.lang.Object content)  
      static java.lang.String jsonDeclaration​(java.lang.String name, java.lang.String[] contents)  
      static java.lang.String jsonDeclaration​(java.lang.String name, java.util.List<?> contents)  
      static java.lang.String jsonDevInfo​(Grant g, java.lang.String module, boolean embedded)
      Development info as JSON string
      static java.lang.String jsonDocument​(Grant g, DocumentDB doc, boolean inlineContent, boolean inlineThumbnail, boolean copy, boolean ids, boolean base64, java.io.File dir, java.lang.String path)
      Builds the JSON object for a document
      static java.lang.String jsonDocument​(Grant g, java.lang.String docId, boolean inlineContent, boolean inlineThumbnail, boolean copy)
      Builds a JSON object for a document
      static java.lang.String jsonDocuments​(Grant g, DocumentDB mdoc, int inlineContent, boolean inlineThumbnail, boolean copy, boolean ids, boolean base64, java.io.File dir, java.lang.String path)
      Builds a JSON object for multi-documents
      static java.lang.String jsonEnclosedDeclaration​(java.lang.String name, java.lang.String content)  
      static java.lang.String jsonEnclosedDeclaration​(java.lang.String name, java.lang.String[] contents)  
      static java.lang.String jsonEnclosedDeclaration​(java.lang.String name, java.util.List<?> contents)  
      static java.lang.String jsonEnclosedStringDeclaration​(java.lang.String name, java.lang.String content)  
      static java.lang.String jsonEnclosedStringDeclaration​(java.lang.String name, java.lang.String[] contents)  
      static java.lang.String jsonEnclosedStringDeclaration​(java.lang.String name, java.util.List<?> contents)  
      static java.lang.String jsonExtObject​(Grant g, java.lang.String name)
      External object meta data as JSON
      static java.lang.String jsonFollow​(Grant g, SocialPost.Author a)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use SocialTool.toJSONAuthor
      static java.lang.String jsonGetSysParam​(Grant g, java.lang.String name)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use getSysParam
      static java.lang.String jsonGetSysParams​(Grant g, boolean embedded)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use getSysParams
      static java.lang.String jsonGrant​(Grant g, boolean inlinePicture, boolean web, boolean embedded)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use Grant.toJSON
      static java.lang.String jsonListOfValue​(Grant g, java.lang.String name, boolean embedded)
      List of values as JSON string
      static java.lang.String jsonMenu​(Grant g, boolean embedded)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Grant.toJSONMenu
      static java.lang.String jsonMetaObject​(Grant g, java.lang.String val, Parameters.InlineParam inlines)
      Builds a JSON object for a meta object value
      static java.lang.String jsonMetaObject​(Grant g, java.lang.String val, java.util.List<java.lang.String> fields, Parameters.InlineParam inlines)
      Builds a JSON object for a meta object value
      static java.lang.String jsonNews​(Grant g, boolean inlineImages, boolean embedded)
      Deprecated.
      Use jsonNews with additional count argument
      static java.lang.String jsonNews​(Grant g, boolean count, boolean inlineImages, boolean embedded)
      News as JSON (limited to visible today and in user's language)
      static java.util.Map<java.lang.String,​java.lang.Object> jsonObjectToMap​(org.json.JSONObject object)
      Convert JSONObject to plain Map
      static java.lang.String jsonPreferences​(ObjectDB obj)
      Object preferences
      static java.lang.String jsonReadDocument​(Grant g, java.lang.String docId, boolean includeContent, boolean includeThumbnail)
      Read document informations as JSON
      static java.lang.String jsonResponse​(java.lang.String type, java.lang.String response)  
      static java.lang.String jsonResponse​(java.lang.String type, java.lang.String response, java.lang.String msg)  
      static java.lang.String jsonSessionInfo​(Grant g, javax.servlet.http.HttpSession session, boolean embedded)
      Session info as JSON string
      { login, id, timeout, created, lastaccess, expires, timezone, licensed, revision, authtoken }
      static java.lang.String jsonSetSysParam​(Grant g, java.lang.String name, java.lang.String value, boolean save)
      Set a session system parameter as JSON
      static java.lang.String jsonString​(java.lang.Object str)
      Get a JSON encoded string
      static java.lang.String jsonStringArray​(java.lang.Object[] strs)  
      static java.lang.String jsonStringArray​(java.util.List<?> contents)  
      static java.lang.String jsonStringDeclaration​(java.lang.String name, java.lang.Object content)  
      static java.lang.String jsonStringDeclaration​(java.lang.String name, java.lang.String[] contents)  
      static java.lang.String jsonStringDeclaration​(java.lang.String name, java.util.List<?> contents)  
      static java.lang.String jsonSysInfo​(Grant g, boolean embedded)
      System info as JSON string
      static java.lang.String jsonTestData​(Grant g, java.lang.String obj, java.lang.String rowId)
      Random data
      static java.lang.String jsonText​(Grant g, java.lang.String code)
      Text as JSON
      static java.lang.String jsonTexts​(Grant g)
      All texts as JSON
      static java.lang.String jsonTextsArray​(Grant g, java.lang.String regex)
      All matching texts as a JSON array
      static DataXML jsonToXML​(org.json.JSONObject item)
      Convert a JSON item to XML data set
      static DataXML jsonToXML​(org.json.JSONObject item, java.util.List<org.json.JSONObject> olditems, ObjectDB obj)
      Convert a JSON item to XML data set
      static DataXML jsonToXML​(org.json.JSONObject item, org.json.JSONObject olditem, ObjectDB obj)
      Convert a JSON item to XML data set
      static java.lang.String jsonUndoRedo​(ObjectDB obj)  
      static java.lang.String jsonUser​(Grant g, java.lang.String login, java.lang.String sessionId, boolean inlinePicture, boolean inlineThumbnail, boolean embedded)
      User as JSON string
      static java.lang.String jsonWriteDocument​(Grant g, java.lang.String docId, java.lang.String name, java.lang.String path, java.lang.String content, java.lang.String object, java.lang.String field, java.lang.String rowId)
      Write document
      static java.lang.String list​(ObjectDB obj, int context, Parameters.ContextParam p, int page, Parameters.InlineParam inlines, boolean embedded, boolean metadata, boolean historic, boolean totals, boolean social, boolean timestamp, boolean visibleOnly, java.lang.String edit, boolean groupby, boolean partial, java.lang.Integer treeDepth)  
      static java.lang.String listAuthors​(Grant g, java.lang.String req, java.lang.String object, boolean all)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use SocialTool.toJSONAuthors
      static java.lang.String listFollows​(Grant g, java.lang.String status)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use SocialTool.toJSONFollowers
      static java.lang.String listSocialPosts​(Grant g, java.lang.String postId, java.lang.String object, java.lang.String rowId, int page, boolean act, boolean follow, boolean countersOnly, boolean audit, java.lang.String level)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use SocialTool.toJSONSocialPosts
      static java.lang.String listToJson​(ObjectDB obj, java.util.List<java.lang.String[]> list, Parameters.InlineParam inlines, int context, Parameters.ContextParam p, boolean metadata, boolean timestamp, boolean visibleOnly, java.lang.String edit)  
      static java.lang.String listTotals​(ObjectDB obj)  
      static java.lang.String lovToJson​(java.util.List<EnumItem> items)
      List of values as JSON
      static java.lang.String mapToJSON​(java.util.Map<java.lang.String,​java.lang.String> map)
      Convert Map to JSON
      static java.lang.String messageToJson​(Grant g, java.lang.String msg, ObjectDB obj)
      Convert a message to JSON { code, level, text, label, field, actions, params }
      static java.lang.String metadata​(ObjectDB obj, int context, Parameters.ContextParam p, java.lang.String[] row)  
      static java.lang.String metadata​(ObjectDB obj, int context, Parameters.ContextParam p, java.lang.String[] row, boolean embedded, boolean init, boolean visibleOnly, java.lang.String edit)  
      static java.lang.String objectFieldMetaDataToJson​(Grant g, ObjectField field)  
      static java.lang.String objectFieldMetaDataToJson​(Grant g, ObjectField field, ObjectDB obj, int context, java.lang.String[] row, java.lang.String editList)
      Field definition
      static java.lang.String objectMetaDataToJson​(ObjectDB obj, int context, Parameters.ContextParam params, java.lang.String[] row, boolean init, boolean visibleOnly, java.lang.String edit)  
      static java.lang.String prepareActionTarget​(Action action)  
      static java.lang.String prepareActionURL​(ObjectDB obj, java.lang.String[] row, Action action)  
      static java.lang.String printTemplateToJson​(ObjectDB obj, java.lang.String[] row, PrintTemplate prt)  
      static java.lang.String processMetadata​(Processus pcs)  
      static java.lang.String processMetadata​(Processus pcs, boolean embedded)  
      static java.lang.String processMetaDataToJson​(Processus pcs)  
      static java.lang.String resourcesToJson​(java.util.List<Resource> resources)  
      static java.lang.String resourceToJson​(Resource r)  
      static java.lang.String rowMetaDataToJson​(ObjectDB obj, int context, Parameters.ContextParam p, java.lang.String[] row, boolean visibleOnly, java.lang.String edit)
      Simplified meta for list rows
      static void savePreferences​(ObjectDB obj, java.lang.String json)  
      static java.lang.String socialCount​(ObjectDB obj)  
      static java.lang.String toJSONName​(java.lang.String name)
      Get JSON name (using Globals.DOT_REPLACEMENT as separator) from internal name (using dots as separator)
      static java.lang.String toYAML​(java.lang.String json)
      Convert JSON string to YAML string
      static java.lang.StringBuilder toYAML​(java.lang.StringBuilder json)
      Convert JSON string builder to YAML string builder
      static java.lang.String toYAML​(org.json.JSONArray json)
      Convert JSON array to YAML
      static java.lang.String toYAML​(org.json.JSONObject json)
      Convert JSON object to YAML
      static java.lang.String transitionMetaDataToJson​(Grant g, Transition t)  
      static java.lang.String viewMetadataToJson​(Grant g, View view, ObjectDB parent, boolean home)
      Deprecated, for removal: This API element is subject to removal in a future version. 
      static java.lang.String warning​(java.lang.String message)  
      static java.lang.String warnings​(java.lang.String[] messages)  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • JSON_DOT_REPLACEMENT

        @Deprecated(forRemoval=false,
                    since="4.0")
        public static final java.lang.String JSON_DOT_REPLACEMENT
        Deprecated.
        Use Globals.DOT_REPLACEMENT
        See Also:
        Constant Field Values
      • EMPTY_JSON_OBJECT

        public static final java.lang.String EMPTY_JSON_OBJECT
        Empty JSON object
        See Also:
        Constant Field Values
      • EMPTY_JSON_ARRAY

        public static final java.lang.String EMPTY_JSON_ARRAY
        Empty JSON array
        See Also:
        Constant Field Values
      • ERRLEVEL_FATAL

        public static final int ERRLEVEL_FATAL
        Fatal error level
        See Also:
        Constant Field Values
      • ERRLEVEL_WARNING

        public static final int ERRLEVEL_WARNING
        Warning level
        See Also:
        Constant Field Values
      • OPENAPI_OAS2_VERSION

        public static final java.lang.String OPENAPI_OAS2_VERSION
        OAS 2 version string
        See Also:
        Constant Field Values
      • OPENAPI_OAS3_VERSION

        public static final java.lang.String OPENAPI_OAS3_VERSION
        OAS 3 version string
        See Also:
        Constant Field Values
      • OPENAPI_BASIC_AUTH

        public static final java.lang.String OPENAPI_BASIC_AUTH
        Basic authentication
        See Also:
        Constant Field Values
      • OPENAPI_BEARER_TOKEN_AUTH

        public static final java.lang.String OPENAPI_BEARER_TOKEN_AUTH
        Bearer token authentication
        See Also:
        Constant Field Values
    • Constructor Detail

      • JSONTool

        public JSONTool()
        Hidden default constructor
    • Method Detail

      • toJSONName

        public static java.lang.String toJSONName​(java.lang.String name)
        Get JSON name (using Globals.DOT_REPLACEMENT as separator) from internal name (using dots as separator)
        Parameters:
        name - Internal name
        Returns:
        JSON name
      • fromJSONName

        public static java.lang.String fromJSONName​(java.lang.String name)
        Get internal name (using dots as separator) from JSON name (using Globals.DOT_REPLACEMENT as separator)
        Parameters:
        name - JSON name
        Returns:
        Internal name
      • jsonArray

        public static java.lang.String jsonArray​(java.lang.Object[] contents)
        Get JSON array from objects array
        Returns:
        JSON array string
      • jsonArray

        public static java.lang.String jsonArray​(double[] vals)
        Get JSON array from doubles array
        Returns:
        JSON array string
      • jsonArray

        public static java.lang.String jsonArray​(java.lang.Double[] vals)
        Get JSON array from Doubles array
        Returns:
        JSON array string
      • jsonArray

        public static java.lang.String jsonArray​(java.util.List<?> contents)
        Get JSON array from object list
        Returns:
        JSON array string
      • jsonString

        public static java.lang.String jsonString​(java.lang.Object str)
        Get a JSON encoded string
        Returns:
        JSON encoded string
      • jsonStringArray

        public static java.lang.String jsonStringArray​(java.lang.Object[] strs)
      • jsonStringArray

        public static java.lang.String jsonStringArray​(java.util.List<?> contents)
      • jsonDeclaration

        public static java.lang.String jsonDeclaration​(ObjectField f)
      • jsonDeclaration

        public static java.lang.String jsonDeclaration​(ObjectField f,
                                                       java.lang.Object value)
      • jsonDeclaration

        public static java.lang.String jsonDeclaration​(java.lang.String name,
                                                       java.lang.Object content)
      • jsonDeclaration

        public static java.lang.String jsonDeclaration​(java.lang.String name,
                                                       boolean content)
      • jsonDeclaration

        public static java.lang.String jsonDeclaration​(java.lang.String name,
                                                       java.lang.Boolean content)
      • jsonDeclaration

        public static java.lang.String jsonDeclaration​(java.lang.String name,
                                                       int content)
      • jsonDeclaration

        public static java.lang.String jsonDeclaration​(java.lang.String name,
                                                       java.lang.Integer content)
      • jsonDeclaration

        public static java.lang.String jsonDeclaration​(java.lang.String name,
                                                       long content)
      • jsonDeclaration

        public static java.lang.String jsonDeclaration​(java.lang.String name,
                                                       java.lang.Long content)
      • jsonDeclaration

        public static java.lang.String jsonDeclaration​(java.lang.String name,
                                                       float content)
      • jsonDeclaration

        public static java.lang.String jsonDeclaration​(java.lang.String name,
                                                       java.lang.Float content)
      • jsonDeclaration

        public static java.lang.String jsonDeclaration​(java.lang.String name,
                                                       double content)
      • jsonDeclaration

        public static java.lang.String jsonDeclaration​(java.lang.String name,
                                                       java.lang.Double content)
      • jsonEnclosedDeclaration

        public static java.lang.String jsonEnclosedDeclaration​(java.lang.String name,
                                                               java.lang.String content)
      • jsonDeclaration

        public static java.lang.String jsonDeclaration​(java.lang.String name,
                                                       java.lang.String[] contents)
      • jsonDeclaration

        public static java.lang.String jsonDeclaration​(java.lang.String name,
                                                       int[] contents)
      • jsonDeclaration

        public static java.lang.String jsonDeclaration​(java.lang.String name,
                                                       long[] contents)
      • jsonDeclaration

        public static java.lang.String jsonDeclaration​(java.lang.String name,
                                                       float[] contents)
      • jsonDeclaration

        public static java.lang.String jsonDeclaration​(java.lang.String name,
                                                       double[] contents)
      • jsonEnclosedDeclaration

        public static java.lang.String jsonEnclosedDeclaration​(java.lang.String name,
                                                               java.lang.String[] contents)
      • jsonDeclaration

        public static java.lang.String jsonDeclaration​(java.lang.String name,
                                                       java.util.List<?> contents)
      • jsonEnclosedDeclaration

        public static java.lang.String jsonEnclosedDeclaration​(java.lang.String name,
                                                               java.util.List<?> contents)
      • jsonStringDeclaration

        public static java.lang.String jsonStringDeclaration​(java.lang.String name,
                                                             java.lang.Object content)
      • jsonEnclosedStringDeclaration

        public static java.lang.String jsonEnclosedStringDeclaration​(java.lang.String name,
                                                                     java.lang.String content)
      • jsonStringDeclaration

        public static java.lang.String jsonStringDeclaration​(java.lang.String name,
                                                             java.lang.String[] contents)
      • jsonEnclosedStringDeclaration

        public static java.lang.String jsonEnclosedStringDeclaration​(java.lang.String name,
                                                                     java.lang.String[] contents)
      • jsonStringDeclaration

        public static java.lang.String jsonStringDeclaration​(java.lang.String name,
                                                             java.util.List<?> contents)
      • jsonEnclosedStringDeclaration

        public static java.lang.String jsonEnclosedStringDeclaration​(java.lang.String name,
                                                                     java.util.List<?> contents)
      • jsonResponse

        public static java.lang.String jsonResponse​(java.lang.String type,
                                                    java.lang.String response)
      • jsonResponse

        public static java.lang.String jsonResponse​(java.lang.String type,
                                                    java.lang.String response,
                                                    java.lang.String msg)
      • getResponse

        public static org.json.JSONObject getResponse​(java.lang.String type,
                                                      java.lang.Object response)
        Get response JSON object
        Parameters:
        type - Response type
        response - Response
      • getResponse

        public static org.json.JSONObject getResponse​(java.lang.String type,
                                                      java.lang.Object response,
                                                      java.lang.String msg)
        Get response JSON object
        Parameters:
        type - Response type
        response - Response
        msg - Message
      • info

        public static java.lang.String info​(java.lang.String message)
      • getInfo

        public static org.json.JSONObject getInfo​(java.lang.String message)
        Get info response
        Parameters:
        message - Info message
      • warning

        public static java.lang.String warning​(java.lang.String message)
      • getWarning

        public static org.json.JSONObject getWarning​(java.lang.String message)
        Get warning response
        Parameters:
        message - Warning message
      • warnings

        public static java.lang.String warnings​(java.lang.String[] messages)
      • getWarnings

        public static org.json.JSONObject getWarnings​(java.lang.String[] messages)
        Get warnings response
        Parameters:
        messages - Warning messages
      • error

        public static java.lang.String error​(java.lang.String message,
                                             int level)
        Error response
        Parameters:
        message - Error message or JSON object
        level - Error level
      • error

        public static java.lang.String error​(java.lang.String message,
                                             int level,
                                             java.lang.String metadata)
        Error response
        Parameters:
        message - Error message or JSON object
        level - Error level
        metadata - Optional metadata
      • error

        public static java.lang.String error​(int status,
                                             java.lang.String message,
                                             int level,
                                             java.lang.String metadata)
        Error response
        Parameters:
        status - HTTP status value (e.g. 404)
        message - Error message or JSON object
        level - Error level
        metadata - Optional metadata
      • getError

        public static org.json.JSONObject getError​(java.lang.Object message,
                                                   int level)
        Get error response
        Parameters:
        message - Error message
        level - Error level
      • getError

        public static org.json.JSONObject getError​(java.lang.Object message,
                                                   int level,
                                                   org.json.JSONObject metadata)
        Get error response
        Parameters:
        message - Error message
        level - Error level
        metadata - Optional metadata
      • getError

        public static org.json.JSONObject getError​(int status,
                                                   java.lang.Object message,
                                                   int level,
                                                   org.json.JSONObject metadata)
        Get error response
        Parameters:
        status - HTTP status value (e.g. 404)
        message - Error message
        level - Error level
        metadata - Optional metadata
      • errors

        public static java.lang.String errors​(java.lang.String[] messages,
                                              int level)
        Errors response
        Parameters:
        messages - Error messages
        level - Errors level
      • errors

        public static java.lang.String errors​(java.lang.String[] messages,
                                              int level,
                                              java.lang.String metadata)
        Errors response
        Parameters:
        messages - Error messages
        level - Errors level
        metadata - Optional metadata
      • errors

        public static java.lang.String errors​(int status,
                                              java.lang.String[] messages,
                                              int level,
                                              java.lang.String metadata)
        Errors response
        Parameters:
        status - HTTP status value (e.g. 404)
        messages - Error messages
        level - Errors level
        metadata - Optional metadata
      • getErrors

        public static org.json.JSONObject getErrors​(java.lang.Object messages,
                                                    int level)
        Get errors response
        Parameters:
        messages - Error messages
        level - Error level
      • getErrors

        public static org.json.JSONObject getErrors​(java.lang.Object messages,
                                                    int level,
                                                    org.json.JSONObject metadata)
        Get errors response
        Parameters:
        messages - Error messages
        level - Error level
        metadata - Optional metadata
      • getErrors

        public static org.json.JSONObject getErrors​(int status,
                                                    java.lang.Object messages,
                                                    int level,
                                                    org.json.JSONObject metadata)
        Get errors response
        Parameters:
        messages - Error messages
        level - Error level
        metadata - Optional metadata
      • messageToJson

        public static java.lang.String messageToJson​(Grant g,
                                                     java.lang.String msg,
                                                     ObjectDB obj)
        Convert a message to JSON { code, level, text, label, field, actions, params }
        Parameters:
        g - Grant
        msg - Formatted message
        obj - Object
        Returns:
        JSON
      • resourceToJson

        public static java.lang.String resourceToJson​(Resource r)
      • resourcesToJson

        public static java.lang.String resourcesToJson​(java.util.List<Resource> resources)
      • objectFieldMetaDataToJson

        public static java.lang.String objectFieldMetaDataToJson​(Grant g,
                                                                 ObjectField field)
      • objectFieldMetaDataToJson

        public static java.lang.String objectFieldMetaDataToJson​(Grant g,
                                                                 ObjectField field,
                                                                 ObjectDB obj,
                                                                 int context,
                                                                 java.lang.String[] row,
                                                                 java.lang.String editList)
        Field definition
        Parameters:
        g - User rights
        field - Field
        obj - Optional object
        context - Object context
        row - Current row (list record or form values)
        editList - Optional edit list mode "new" or "rows"
        Returns:
        JSON
      • initWebService

        public static ObjectContextWeb initWebService​(ObjectDB obj,
                                                      int context,
                                                      Parameters.ContextParam p,
                                                      boolean apply,
                                                      java.lang.String edit)
        Prepare the object context for web service
        Parameters:
        obj - Object
        context - Object context
        p - Optional context parameters
        apply - true to apply init hook and user filters
        edit - optional edit mode
        Returns:
        Object context
      • jsonUndoRedo

        public static java.lang.String jsonUndoRedo​(ObjectDB obj)
      • objectMetaDataToJson

        public static java.lang.String objectMetaDataToJson​(ObjectDB obj,
                                                            int context,
                                                            Parameters.ContextParam params,
                                                            java.lang.String[] row,
                                                            boolean init,
                                                            boolean visibleOnly,
                                                            java.lang.String edit)
      • rowMetaDataToJson

        public static java.lang.String rowMetaDataToJson​(ObjectDB obj,
                                                         int context,
                                                         Parameters.ContextParam p,
                                                         java.lang.String[] row,
                                                         boolean visibleOnly,
                                                         java.lang.String edit)
        Simplified meta for list rows
      • printTemplateToJson

        public static java.lang.String printTemplateToJson​(ObjectDB obj,
                                                           java.lang.String[] row,
                                                           PrintTemplate prt)
      • actionToJson

        public static java.lang.String actionToJson​(ObjectDB obj,
                                                    Action action,
                                                    java.lang.String[] row,
                                                    boolean create,
                                                    int context)
      • prepareActionURL

        public static java.lang.String prepareActionURL​(ObjectDB obj,
                                                        java.lang.String[] row,
                                                        Action action)
      • prepareActionTarget

        public static java.lang.String prepareActionTarget​(Action action)
      • filtersToJson

        public static java.lang.String filtersToJson​(ObjectDB obj,
                                                     boolean reset,
                                                     boolean limited)
        JSON filters in service format
        Parameters:
        obj - Object
        reset - Reset filters first ?
        limited - get valued filter only ?
        Returns:
        JSON
      • fieldValue

        public static java.lang.String fieldValue​(ObjectField field)
      • fieldValue

        public static java.lang.String fieldValue​(ObjectField field,
                                                  java.lang.String value)
      • functIdToJson

        public static java.lang.String functIdToJson​(ObjectDB obj)
      • fieldsToJson

        public static java.lang.String fieldsToJson​(ObjectDB obj)
      • fieldsToJson

        public static java.lang.String fieldsToJson​(ObjectDB obj,
                                                    Parameters.InlineParam inlines,
                                                    java.lang.String[] fields,
                                                    boolean onlyFunctIds,
                                                    boolean timestamps)
      • listToJson

        public static java.lang.String listToJson​(ObjectDB obj,
                                                  java.util.List<java.lang.String[]> list,
                                                  Parameters.InlineParam inlines,
                                                  int context,
                                                  Parameters.ContextParam p,
                                                  boolean metadata,
                                                  boolean timestamp,
                                                  boolean visibleOnly,
                                                  java.lang.String edit)
      • groupByToJson

        public static java.lang.String groupByToJson​(ObjectDB obj,
                                                     java.util.List<java.lang.String[]> list)
      • metadata

        public static java.lang.String metadata​(ObjectDB obj,
                                                int context,
                                                Parameters.ContextParam p,
                                                java.lang.String[] row,
                                                boolean embedded,
                                                boolean init,
                                                boolean visibleOnly,
                                                java.lang.String edit)
      • filters

        public static java.lang.String filters​(ObjectDB obj,
                                               boolean reset)
      • filters

        public static java.lang.String filters​(ObjectDB obj,
                                               int context,
                                               boolean reset)
      • filters

        public static java.lang.String filters​(ObjectDB obj,
                                               int context,
                                               boolean reset,
                                               boolean embedded)
      • get

        public static java.lang.String get​(ObjectDB obj,
                                           java.lang.String rowId)
                                    throws GetException
        Get object record as JSON
        Parameters:
        obj - Business object
        rowId - Object row ID
        Returns:
        JSON
        Throws:
        GetException - If get fails
      • get

        public static java.lang.String get​(ObjectDB obj,
                                           java.lang.String rowId,
                                           boolean embedded)
                                    throws GetException
        Get object record as JSON
        Parameters:
        obj - Business object
        rowId - Object row ID
        embedded - True to return data without a json response container
        Returns:
        JSON
        Throws:
        GetException - If get fails
      • get

        public static java.lang.String get​(ObjectDB obj,
                                           java.lang.String rowId,
                                           int context,
                                           java.lang.String[] fields,
                                           Parameters.InlineParam inlines,
                                           boolean embedded)
                                    throws GetException
        Get object record as JSON
        Parameters:
        obj - Business object
        rowId - Object row ID
        context - Context (none, update, create...) from ObjectDB.CONTEXT_*
        fields - Optional list of fields to return (default return all fields)
        inlines - Options to return inlined documents
        embedded - True to return data without a json response container
        Returns:
        JSON
        Throws:
        GetException - If get fails
      • get

        @Deprecated(forRemoval=true,
                    since="4.0")
        public static java.lang.String get​(ObjectDB obj,
                                           java.lang.String rowId,
                                           int context,
                                           boolean timestamps,
                                           java.lang.String[] fields,
                                           Parameters.InlineParam inlines,
                                           boolean embedded,
                                           boolean metadata,
                                           Parameters.ContextParam parent,
                                           boolean social,
                                           java.util.List<java.lang.String> msgs,
                                           TreeView tv,
                                           TreeView.TreeViewNode tvNode,
                                           int tvDepth)
                                    throws GetException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Use get with additional argument
        Throws:
        GetException
      • get

        @Deprecated(forRemoval=true,
                    since="4.0")
        public static java.lang.String get​(ObjectDB obj,
                                           java.lang.String rowId,
                                           int context,
                                           boolean timestamps,
                                           java.lang.String[] fields,
                                           Parameters.InlineParam inlines,
                                           boolean embedded,
                                           boolean metadata,
                                           Parameters.ContextParam parent,
                                           boolean social,
                                           boolean share,
                                           java.util.List<java.lang.String> msgs,
                                           TreeView tv,
                                           TreeView.TreeViewNode tvNode,
                                           int tvDepth)
                                    throws GetException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Use get with additional argument
        Throws:
        GetException
      • get

        public static java.lang.String get​(ObjectDB obj,
                                           java.lang.String rowId,
                                           int context,
                                           boolean timestamps,
                                           java.lang.String[] fields,
                                           ServletParameters values,
                                           Parameters.InlineParam inlines,
                                           boolean embedded,
                                           boolean metadata,
                                           Parameters.ContextParam parent,
                                           boolean social,
                                           boolean share,
                                           java.util.List<java.lang.String> msgs,
                                           Parameters.TreeviewParam tv)
                                    throws GetException
        Get object record as JSON
        Parameters:
        obj - Business object
        rowId - Object row ID
        context - Context (none, update, create...) from ObjectDB.CONTEXT_*
        timestamps - True to return the timestamps of record
        fields - Optional list of fields to return (default return all fields)
        values - Optional field values to set and foreign keys to complete/populate
        inlines - Options to return inlined documents
        embedded - True to return data without a json response container
        metadata - True to return metadata of object in that context
        parent - Optional parent object context
        social - True to count posts for this record
        share - True to get social data to share for this record
        msgs - Optional messages to return
        tv - Optional treeview parameters to get a record tree
        Returns:
        JSON
        Throws:
        GetException - If get fails
      • document

        public static java.lang.String document​(ObjectDB obj,
                                                java.lang.String rowId,
                                                java.lang.String field)
                                         throws GetException
        Throws:
        GetException
      • document

        public static java.lang.String document​(ObjectDB obj,
                                                java.lang.String rowId,
                                                java.lang.String field,
                                                boolean embedded,
                                                boolean copy)
                                         throws GetException
        Throws:
        GetException
      • list

        public static java.lang.String list​(ObjectDB obj,
                                            int context,
                                            Parameters.ContextParam p,
                                            int page,
                                            Parameters.InlineParam inlines,
                                            boolean embedded,
                                            boolean metadata,
                                            boolean historic,
                                            boolean totals,
                                            boolean social,
                                            boolean timestamp,
                                            boolean visibleOnly,
                                            java.lang.String edit,
                                            boolean groupby,
                                            boolean partial,
                                            java.lang.Integer treeDepth)
      • count

        public static java.lang.String count​(ObjectDB obj)
      • count

        public static java.lang.String count​(ObjectDB obj,
                                             boolean metadata)
      • listTotals

        public static java.lang.String listTotals​(ObjectDB obj)
      • historic

        public static java.lang.String historic​(ObjectDB obj,
                                                int page)
      • socialCount

        public static java.lang.String socialCount​(ObjectDB obj)
      • processMetaDataToJson

        public static java.lang.String processMetaDataToJson​(Processus pcs)
      • activityMetaDataToJson

        public static java.lang.String activityMetaDataToJson​(Activity a)
      • transitionMetaDataToJson

        public static java.lang.String transitionMetaDataToJson​(Grant g,
                                                                Transition t)
      • processMetadata

        public static java.lang.String processMetadata​(Processus pcs)
      • processMetadata

        public static java.lang.String processMetadata​(Processus pcs,
                                                       boolean embedded)
      • getProcessExternalContent

        public static java.lang.String getProcessExternalContent​(Processus p,
                                                                 ActivityFile context,
                                                                 ObjectContextWeb ctx)
        Prepare content of external activity (Page.Method)
      • activityData

        public static java.lang.String activityData​(Processus pcs,
                                                    ActivityFile af,
                                                    ObjectDB object,
                                                    boolean metadata,
                                                    boolean embedded)
      • indexMetaDataToJson

        public static java.lang.String indexMetaDataToJson​(Grant g)
        Index metadata as JSON string
        Parameters:
        g - Grant
        Returns:
        JSON string
      • jsonSessionInfo

        public static java.lang.String jsonSessionInfo​(Grant g,
                                                       javax.servlet.http.HttpSession session,
                                                       boolean embedded)
        Session info as JSON string
        { login, id, timeout, created, lastaccess, expires, timezone, licensed, revision, authtoken }
        Parameters:
        g - Grant
        session - Session
        embedded - Embedded ?
        Returns:
        JSON string
      • jsonAppInfo

        public static java.lang.String jsonAppInfo​(Grant g,
                                                   boolean embedded)
        Application info as JSON string
        Parameters:
        g - Grant
        embedded - Embedded ?
        Returns:
        JSON string
      • jsonSysInfo

        public static java.lang.String jsonSysInfo​(Grant g,
                                                   boolean embedded)
        System info as JSON string
        Parameters:
        g - Grant
        embedded - Embedded ?
        Returns:
        JSON string
      • jsonDevInfo

        public static java.lang.String jsonDevInfo​(Grant g,
                                                   java.lang.String module,
                                                   boolean embedded)
        Development info as JSON string
        Parameters:
        g - Grant
        module - Optional module name
        embedded - Embedded ?
        Returns:
        JSON string
      • viewMetadataToJson

        @Deprecated(forRemoval=true,
                    since="4.0")
        public static java.lang.String viewMetadataToJson​(Grant g,
                                                          View view,
                                                          ObjectDB parent,
                                                          boolean home)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Use View.toJSON
      • jsonGrant

        @Deprecated(forRemoval=true,
                    since="4.0")
        public static java.lang.String jsonGrant​(Grant g,
                                                 boolean inlinePicture,
                                                 boolean web,
                                                 boolean embedded)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Use Grant.toJSON
      • jsonUser

        public static java.lang.String jsonUser​(Grant g,
                                                java.lang.String login,
                                                java.lang.String sessionId,
                                                boolean inlinePicture,
                                                boolean inlineThumbnail,
                                                boolean embedded)
        User as JSON string
        Parameters:
        g - Grant
        login - User login
        sessionId - Optional user session Id
        inlinePicture - Inline picture content ?
        inlineThumbnail - Inline picture thumbnail ?
        Returns:
        JSON string
      • jsonListOfValue

        public static java.lang.String jsonListOfValue​(Grant g,
                                                       java.lang.String name,
                                                       boolean embedded)
        List of values as JSON string
        Parameters:
        g - Grant
        name - List of value name
        Returns:
        JSON string
      • lovToJson

        public static java.lang.String lovToJson​(java.util.List<EnumItem> items)
        List of values as JSON
        Parameters:
        items - Items
        Returns:
        JSON
      • jsonGetSysParams

        @Deprecated(forRemoval=true,
                    since="4.0")
        public static java.lang.String jsonGetSysParams​(Grant g,
                                                        boolean embedded)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Use getSysParams
      • getHistoryName

        public static java.lang.String getHistoryName​(Grant g)
      • getZoomName

        public static java.lang.String getZoomName​(Grant g)
      • getCompactName

        public static java.lang.String getCompactName​(Grant g)
      • getSysParams

        public static org.json.JSONObject getSysParams​(Grant g,
                                                       boolean embedded)
        Get all session system parameters as JSON oject
        Parameters:
        g - Grant
        Returns:
        JSON object
      • jsonGetSysParam

        @Deprecated(forRemoval=true,
                    since="4.0")
        public static java.lang.String jsonGetSysParam​(Grant g,
                                                       java.lang.String name)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Use getSysParam
      • getSysParam

        public static org.json.JSONObject getSysParam​(Grant g,
                                                      java.lang.String name)
        Get a single session system parameter as JSON
        Parameters:
        g - Grant
        name - System parameter name
        Returns:
        JSON
      • getSysParam

        public static org.json.JSONObject getSysParam​(Grant g,
                                                      java.lang.String name,
                                                      boolean force)
        Get a single system parameter as JSON
        Parameters:
        g - Grant
        name - System parameter name
        force - Force read system parameter (if false the session's value is returned)
        Returns:
        JSON
      • jsonSetSysParam

        public static java.lang.String jsonSetSysParam​(Grant g,
                                                       java.lang.String name,
                                                       java.lang.String value,
                                                       boolean save)

        Set a session system parameter as JSON

        Parameters:
        g - Grant
        name - System parameter name
        value - System parameter value (remove if null)
        save - Save as user system parameter
        Returns:
        JSON
      • jsonText

        public static java.lang.String jsonText​(Grant g,
                                                java.lang.String code)

        Text as JSON

        Parameters:
        g - Grant
        code - Text code
      • jsonTextsArray

        public static java.lang.String jsonTextsArray​(Grant g,
                                                      java.lang.String regex)

        All matching texts as a JSON array

        Parameters:
        g - Grant
        regex - Filtering regex on codes
        Returns:
        JSON array
      • jsonTexts

        public static java.lang.String jsonTexts​(Grant g)

        All texts as JSON

        Parameters:
        g - Grant
        Returns:
        JSON
      • getTexts

        @Deprecated(forRemoval=false,
                    since="4.0")
        public static java.lang.String getTexts​(Grant g)
        Deprecated.
        Use Grant.toJSONTexts
      • getTexts

        @Deprecated(forRemoval=false,
                    since="4.0")
        public static java.lang.String getTexts​(Grant g,
                                                java.lang.String regex)
        Deprecated.
        Use Grant.toJSONTexts
      • jsonMenu

        @Deprecated(forRemoval=true,
                    since="4.0")
        public static java.lang.String jsonMenu​(Grant g,
                                                boolean embedded)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Grant.toJSONMenu
      • jsonPreferences

        public static java.lang.String jsonPreferences​(ObjectDB obj)
        Object preferences
        Parameters:
        obj - Business object
        Returns:
        JSON
      • savePreferences

        public static void savePreferences​(ObjectDB obj,
                                           java.lang.String json)
      • listSocialPosts

        @Deprecated(forRemoval=true,
                    since="4.0")
        public static java.lang.String listSocialPosts​(Grant g,
                                                       java.lang.String postId,
                                                       java.lang.String object,
                                                       java.lang.String rowId,
                                                       int page,
                                                       boolean act,
                                                       boolean follow,
                                                       boolean countersOnly,
                                                       boolean audit,
                                                       java.lang.String level)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Use SocialTool.toJSONSocialPosts
      • jsonFollow

        @Deprecated(forRemoval=true,
                    since="4.0")
        public static java.lang.String jsonFollow​(Grant g,
                                                  SocialPost.Author a)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Use SocialTool.toJSONAuthor
      • listFollows

        @Deprecated(forRemoval=true,
                    since="4.0")
        public static java.lang.String listFollows​(Grant g,
                                                   java.lang.String status)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Use SocialTool.toJSONFollowers
      • listAuthors

        @Deprecated(forRemoval=true,
                    since="4.0")
        public static java.lang.String listAuthors​(Grant g,
                                                   java.lang.String req,
                                                   java.lang.String object,
                                                   boolean all)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Use SocialTool.toJSONAuthors
      • jsonNews

        @Deprecated(forRemoval=false,
                    since="5")
        public static java.lang.String jsonNews​(Grant g,
                                                boolean inlineImages,
                                                boolean embedded)
        Deprecated.
        Use jsonNews with additional count argument
      • jsonNews

        public static java.lang.String jsonNews​(Grant g,
                                                boolean count,
                                                boolean inlineImages,
                                                boolean embedded)
        News as JSON (limited to visible today and in user's language)
        Parameters:
        count - Count only?
        inlineImages - Inline images contents (not used if count is true?
        embedded - True to return data without a json response container
        Returns:
        JSON string
      • jsonMetaObject

        public static java.lang.String jsonMetaObject​(Grant g,
                                                      java.lang.String val,
                                                      Parameters.InlineParam inlines)
        Builds a JSON object for a meta object value
        Parameters:
        g - Grant
        val - Meta object value
        inlines - Inline documents options
        Returns:
        JSON string
      • jsonMetaObject

        public static java.lang.String jsonMetaObject​(Grant g,
                                                      java.lang.String val,
                                                      java.util.List<java.lang.String> fields,
                                                      Parameters.InlineParam inlines)
        Builds a JSON object for a meta object value
        Parameters:
        g - Grant
        val - Meta object value
        fields - Fields
        inlines - Inline documents options
        Returns:
        JSON string
      • jsonDocuments

        public static java.lang.String jsonDocuments​(Grant g,
                                                     DocumentDB mdoc,
                                                     int inlineContent,
                                                     boolean inlineThumbnail,
                                                     boolean copy,
                                                     boolean ids,
                                                     boolean base64,
                                                     java.io.File dir,
                                                     java.lang.String path)

        Builds a JSON object for multi-documents

        Parameters:
        g - Grant
        mdoc - Multi-documents
        inlineContent - Include document id, data or content (base64 encoded string)
        inlineThumbnail - Inline document thumbnail content (base64 encoded string)
        copy - Serialize for copy ?
        dir - optional directory to map files
        path - relative field path to map files
        Returns:
        json array
      • jsonDocument

        public static java.lang.String jsonDocument​(Grant g,
                                                    java.lang.String docId,
                                                    boolean inlineContent,
                                                    boolean inlineThumbnail,
                                                    boolean copy)
        Builds a JSON object for a document
        Parameters:
        g - Grant
        docId - Document ID
        inlineContent - Include document content (base64 encoded string)
        inlineThumbnail - Include document thumbnail content (base64 encoded string)
        Returns:
        JSON
      • jsonDocument

        public static java.lang.String jsonDocument​(Grant g,
                                                    DocumentDB doc,
                                                    boolean inlineContent,
                                                    boolean inlineThumbnail,
                                                    boolean copy,
                                                    boolean ids,
                                                    boolean base64,
                                                    java.io.File dir,
                                                    java.lang.String path)
        Builds the JSON object for a document
        Parameters:
        g - Grant
        doc - Document
        inlineContent - Include document content (base64 encoded string)
        inlineThumbnail - Inline document thumbnail content (base64 encoded string)
        copy - Serialize for copy?
        ids - with ids, mime, size, field and dbdoc path?
        base64 - encoded in base64? (forced to true on binary file)
        dir - optional directory to map files
        path - optional relative path to save the file
        Returns:
        JSON string
      • jsonReadDocument

        public static java.lang.String jsonReadDocument​(Grant g,
                                                        java.lang.String docId,
                                                        boolean includeContent,
                                                        boolean includeThumbnail)
        Read document informations as JSON
        Parameters:
        g - Grant
        docId - Document ID
        includeContent - Include document content (base64 encoded string)
        includeThumbnail - Include document thumbnail content (base64 encoded string)
        Returns:
        JSON string
      • jsonWriteDocument

        public static java.lang.String jsonWriteDocument​(Grant g,
                                                         java.lang.String docId,
                                                         java.lang.String name,
                                                         java.lang.String path,
                                                         java.lang.String content,
                                                         java.lang.String object,
                                                         java.lang.String field,
                                                         java.lang.String rowId)
        Write document
        Parameters:
        g - Grant
        name - Document name
        content - Document content (base64 encoded string)
        Returns:
        JSON string
      • jsonExtObject

        public static java.lang.String jsonExtObject​(Grant g,
                                                     java.lang.String name)
        External object meta data as JSON
        Parameters:
        name - External object name
        Returns:
        JSON string
      • jsonToXML

        public static DataXML jsonToXML​(org.json.JSONObject item)
        Convert a JSON item to XML data set
        Parameters:
        item - JSON object with fields
      • jsonToXML

        public static DataXML jsonToXML​(org.json.JSONObject item,
                                        org.json.JSONObject olditem,
                                        ObjectDB obj)
        Convert a JSON item to XML data set
        Parameters:
        item - JSON object with current field values
        olditem - JSON object with old field values
        obj - Optional to order fields
      • jsonToXML

        public static DataXML jsonToXML​(org.json.JSONObject item,
                                        java.util.List<org.json.JSONObject> olditems,
                                        ObjectDB obj)
        Convert a JSON item to XML data set
        Parameters:
        item - JSON object with current field values
        olditems - JSON objects with old field values
        obj - Optional to order fields
      • jsonObjectToMap

        public static java.util.Map<java.lang.String,​java.lang.Object> jsonObjectToMap​(org.json.JSONObject object)
        Convert JSONObject to plain Map
      • mapToJSON

        public static java.lang.String mapToJSON​(java.util.Map<java.lang.String,​java.lang.String> map)
        Convert Map to JSON
      • addOpenAPIParameterType

        public static org.json.JSONObject addOpenAPIParameterType​(org.json.JSONObject param,
                                                                  java.lang.String type,
                                                                  org.json.JSONArray values,
                                                                  int spec)
        Add OpenAPI parameter type
        Parameters:
        param - Parameter object
        type - Type
        values - Values
        spec - OpenAPI specification
        Returns:
        JSON object
      • addOpenAPIParameterType

        public static org.json.JSONObject addOpenAPIParameterType​(org.json.JSONObject param,
                                                                  java.lang.String type,
                                                                  java.lang.String format,
                                                                  java.lang.String pattern,
                                                                  org.json.JSONArray values,
                                                                  int spec)
        Add OpenAPI parameter type
        Parameters:
        param - Parameter object
        type - Type
        format - String format
        pattern - String pattern
        values - Values
        spec - OpenAPI specification
        Returns:
        JSON object
      • addOpenAPIOperationType

        public static org.json.JSONObject addOpenAPIOperationType​(org.json.JSONObject operation,
                                                                  java.lang.String requestType,
                                                                  java.lang.String requestSchema,
                                                                  java.lang.String responseType,
                                                                  java.lang.String responseSchema,
                                                                  int[] errorStatuses,
                                                                  int spec)
        Get OpenAPI operation types
        Parameters:
        operation - Operation
        requestType - Request type
        requestSchema - Request schema
        responseType - Response type
        responseSchema - Response schema
        errorStatuses - Error statuses
        spec - OpenAPI specification
        Returns:
        JSON object
      • addOpenAPIOperationTypes

        public static org.json.JSONObject addOpenAPIOperationTypes​(org.json.JSONObject operation,
                                                                   java.lang.String[] requestTypes,
                                                                   java.lang.String requestSchema,
                                                                   java.lang.String[] responseTypes,
                                                                   java.lang.String responseSchema,
                                                                   int[] errorStatuses,
                                                                   int spec)
        Get OpenAPI operation types
        Parameters:
        operation - Operation
        requestTypes - Request types
        requestSchema - Request schema
        responseTypes - Response types
        responseSchema - Response schema
        errorStatuses - Error statuses
        spec - OpenAPI specification
        Returns:
        JSON object
      • getOpenAPIRef

        public static java.lang.String getOpenAPIRef​(java.lang.String name,
                                                     int spec)
        Get OpenAPI reference
        Parameters:
        name - Reference name
        spec - OpenAPI specification
        Returns:
        JSON object
      • getOpenAPIError

        public static org.json.JSONObject getOpenAPIError​(int code,
                                                          int spec)
        Get OpenAPI error
        Parameters:
        code - Error code
        spec - OpenAPI specification
        Returns:
        JSON object
      • getOpenAPIInfo

        public static org.json.JSONObject getOpenAPIInfo​(java.lang.String title,
                                                         java.lang.String desc,
                                                         java.lang.String version,
                                                         boolean license,
                                                         boolean contact)
        Get OpenAPI info
        Parameters:
        title - Title
        desc - Description
        version - Version
        license - License?
        contact - Contact?
        Returns:
        JSON object
      • addTag

        public static org.json.JSONArray addTag​(org.json.JSONArray tags,
                                                java.lang.String name,
                                                java.lang.String desc)
        Add a tag
        Parameters:
        tags - Tag list (or null)
        name - Tag name
        desc - Tag description
      • getOpenAPISchema

        @Deprecated(forRemoval=false,
                    since="4.0")
        public static org.json.JSONObject getOpenAPISchema​(Grant g,
                                                           int spec,
                                                           org.json.JSONObject info,
                                                           org.json.JSONArray tags,
                                                           java.lang.String basePath,
                                                           org.json.JSONObject paths,
                                                           org.json.JSONObject schemas)
        Deprecated.
        Use getOpenAPISchema with security argument
      • getOpenAPISchema

        public static org.json.JSONObject getOpenAPISchema​(Grant g,
                                                           int spec,
                                                           org.json.JSONObject info,
                                                           org.json.JSONArray tags,
                                                           java.lang.String basePath,
                                                           org.json.JSONObject paths,
                                                           org.json.JSONObject schemas,
                                                           boolean security)
        Get OpenAPI schema
        Parameters:
        g - Grant
        spec - OpenAPI specification
        info - Info
        tags - Tags
        basePath - Base path
        paths - Paths
        schemas - Schemas
        security - Security schemes?
        Returns:
        JSON object
      • addOpenAPIErrorsSchemas

        public static org.json.JSONObject addOpenAPIErrorsSchemas​(org.json.JSONObject schemas,
                                                                  int[] errs,
                                                                  int spec)
        Add OpenAPI errors schemas
        Parameters:
        schemas - Schemas to add errors schemas to
        errs - Error codes (defaults to 400, 401, 403, 404 and 500)
        spec - OpenAPI specification
        Returns:
        Updated schemas
      • addLoginOpenAPIPath

        public static org.json.JSONObject addLoginOpenAPIPath​(org.json.JSONObject paths,
                                                              int spec)
        Add login service OpenAPI path description to paths
        Parameters:
        paths - Paths
        spec - OpenAPI specification
        Returns:
        Updated paths
      • addLogoutOpenAPIPath

        public static org.json.JSONObject addLogoutOpenAPIPath​(org.json.JSONObject paths,
                                                               int spec)
        Add logout service OpenAPI path description to paths
        Parameters:
        paths - Paths
        spec - OpenAPI specification
        Returns:
        Updated paths
      • addActionResultSchema

        public static org.json.JSONObject addActionResultSchema​(org.json.JSONObject schemas)
        Add action result OpenAPI schemas description to schemas
        Parameters:
        schemas - Schemas
        Returns:
        Updated schemas
      • addPublicationResultSchema

        public static org.json.JSONObject addPublicationResultSchema​(org.json.JSONObject schemas)
        Add publication result OpenAPI schemas description to schemas
        Parameters:
        schemas - Schemas
        Returns:
        Updated schemas
      • addPlaceMapSchema

        public static org.json.JSONObject addPlaceMapSchema​(org.json.JSONObject schemas,
                                                            int spec)
        Add placemap result OpenAPI schemas description to schemas
        Parameters:
        schemas - Schemas
        spec - OpenAPI specification
        Returns:
        Updated schemas
      • addTreeviewDataSchema

        public static org.json.JSONObject addTreeviewDataSchema​(org.json.JSONObject schemas)
        Add treeview data OpenAPI schemas description to schemas
        Parameters:
        schemas - Schemas
        Returns:
        JSONObject
      • addErrorsSchema

        public static org.json.JSONObject addErrorsSchema​(org.json.JSONObject schemas)
        Add error messages OpenAPI schemas description to schemas
        Parameters:
        schemas - Schemas
        Returns:
        Updated schemas
      • addAppSessionOpenAPIPath

        public static org.json.JSONObject addAppSessionOpenAPIPath​(org.json.JSONObject paths,
                                                                   int spec)
        Add application and session REST services OpenAPI paths description to paths
        Parameters:
        paths - Paths
        spec - OpenAPI specification
        Returns:
        Updated paths
      • addBusinessObjectOpenAPISchema

        public static org.json.JSONObject addBusinessObjectOpenAPISchema​(org.json.JSONObject schemas,
                                                                         ObjectDB obj,
                                                                         int spec)
        Add business object REST services OpenAPI schema to schemas
        Parameters:
        schemas - Schemas
        obj - Business object
        spec - OpenAPI specification
        Returns:
        Updated schemas
      • addBusinessObjectOpenAPIPath

        public static org.json.JSONObject addBusinessObjectOpenAPIPath​(org.json.JSONObject paths,
                                                                       ObjectDB obj,
                                                                       java.lang.String relPath,
                                                                       int spec)
        Add business object REST services OpenAPI paths to paths
        Parameters:
        paths - Paths
        obj - Business object
        relPath - Relative path to base path
        spec - OpenAPI specification
        Returns:
        Updated paths
      • getJSONSchema

        public static org.json.JSONObject getJSONSchema​(ObjectDB obj)
        Get JSON Schema for specified object
        Parameters:
        obj - Object
        Returns:
        JSON schema
      • jsonTestData

        public static java.lang.String jsonTestData​(Grant g,
                                                    java.lang.String obj,
                                                    java.lang.String rowId)
                                             throws GrantException
        Random data
        Parameters:
        g - Grant
        obj - Object name
        rowId - Optional row ID
        Throws:
        GrantException
      • getJSONObjectFromXML

        public static org.json.JSONObject getJSONObjectFromXML​(java.lang.String xml)
        Get JSON object from XML
        Parameters:
        xml - XML string
        Returns:
        JSON object or null if XML is not parseable as JSON object
      • getXMLFromJSONObject

        public static java.lang.String getXMLFromJSONObject​(org.json.JSONObject json)
        Get XML from JSON objectL
        Parameters:
        json - JSON object
        Returns:
        XML string or null is JSON object is to parseable as XML
      • getJSONASCIILogo

        public static java.lang.String getJSONASCIILogo​(java.lang.String complement)
        Get ASCII logo as JSON comments
        Parameters:
        complement - Additonal string to append to logo
      • getYAMLASCIILogo

        public static java.lang.String getYAMLASCIILogo​(java.lang.String complement)
        Get ASCII logo as YAML comments
        Parameters:
        complement - Additonal string to append to logo
      • getYAMLProcessor

        public static org.yaml.snakeyaml.Yaml getYAMLProcessor()
        Get YAML processor
      • toYAML

        public static java.lang.String toYAML​(org.json.JSONObject json)
        Convert JSON object to YAML
        Parameters:
        json - JSON object
        Returns:
        YAML string
      • toYAML

        public static java.lang.String toYAML​(org.json.JSONArray json)
        Convert JSON array to YAML
        Parameters:
        json - JSON array
        Returns:
        YAML string
      • toYAML

        public static java.lang.String toYAML​(java.lang.String json)
        Convert JSON string to YAML string
        Parameters:
        json - JSON string
        Returns:
        YAML string
      • toYAML

        public static java.lang.StringBuilder toYAML​(java.lang.StringBuilder json)
        Convert JSON string builder to YAML string builder
        Parameters:
        json - JSON string builder
        Returns:
        YAML string builder
      • fromYAMLToJSONArray

        public static org.json.JSONArray fromYAMLToJSONArray​(java.lang.String yaml)
        Convert YAML to JSON array
        Parameters:
        yaml - YAML string
        Returns:
        JSON array
      • fromYAMLToJSONObject

        public static org.json.JSONObject fromYAMLToJSONObject​(java.lang.String yaml)
        Convert YAML to JSON object
        Parameters:
        yaml - YAML string
        Returns:
        JSON object
      • fromYAML

        public static org.json.JSONObject fromYAML​(java.lang.String yaml)
        Convert YAML to JSON object (alias to fromYAMLToJSONObject
        Parameters:
        yaml - YAML string
        Returns:
        JSON object