Skip to content

Latest commit

 

History

History
138 lines (110 loc) · 4.01 KB

File metadata and controls

138 lines (110 loc) · 4.01 KB

#API Object: OWF.Preferences.getUserPreference(cfg)#

#####Definition: Use the /getUserPreference API to return a user preference based on its namespace and name. The preference could be user metadata such as name, email, etc.

#####How it works:##### A system makes a call to another system that asks to reference data instead of return it. To make this call, one of the following REST Calls will request user data from the user profile URI [IS THIS RIGHT?]

#####Request URL:#####

https://localhost:8443/owf/prefs/preference/com.company.widget/First%20President?version=7.15.0-v1&dojo.preventCache=1433176043577

#####Request Method:##### GET, Form_Method:none

#####Requirements:##### The call must include namespace. Name is optional.

  • If name is a non-null empty string, it will return all preferences with a matching namespace.
  • If namespace is a non-null empty string, it will throw an HTML 404 error, “The requested resource is not available.”
  • If name or namespace are null it will fill them in with “undefined” and perform the request using 'undefined' as the name or namespace.

#####Response:##### When you provide the namespace and name and the system finds a matching preference, it will return the preference information:

{"id":157,"namespace":"com.company.widget","path":"First President","value":"fooval","user":{"userId":"testUser1"}}

#####How to use it:##### This API provides additional metadata about a preference.


###Example###

The following is an example of a call to get a user preference:

{
  "success": true,
  "results": 3,
  "rows": [
    {
      "id": 144,
      "namespace": "com.company.widget",
      "path": "First President",
      "value": "foovalue",
      "user": {
        "userId": "testUser1"
      }
    },
    {
      "id": 146,
      "namespace": "com.company.widget",
      "path": "Second President",
      "value": "foovalue",
      "user": {
        "userId": "testUser2"
      }
    },
    {
      "id": 157,
      "namespace": "com.company.widget",
      "path": "First Vice President",
      "value": "fooval",
      "user": {
        "userId": "testAdmin1"
      }
    }
  ]
}

If the system does not find a matching preference, it will return:

{"success":true,"preference":null}

Example:

function onSuccess(pref) {alert(pref.value);}
function onFailure(error,status) {
    alert('Error ' + error);
    alert(status);
}
var cfg = {
    namespace: 'com.company.widget',
    name: 'First President',
    onSuccess: onSuccess,
    onFailure: onFailure
};

OWF.Preferences.getUserPreference(cfg);

###Resource Information###

Parameter Description
{Object} cfg Use the following properties to configure the object.
{String} cfg.namespace The namespace of the user preference.
{String} cfg.name The name of the user preference.
{Function} cfg.onSuccess The function that will be called if the user preference is successfully deleted from the database.
{Function} cfg.onFailure Optional The system returns this function if the user preference cannot be deleted from the database or if the preference does not exist. If this function is not specified a default error message display.
This function passes back the following parameters:
error: String
Status: The HTTP Status code

###Possible Errors###

Error Action
HTTP Status 404: “The requested resource is not available” Enter a value in the namespace.