Skip to content

Latest commit

 

History

History
106 lines (85 loc) · 3.55 KB

File metadata and controls

106 lines (85 loc) · 3.55 KB

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

#####Definition: Use the /setUserPreference API to change 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 change data about a preference for example...ADD EXAMPLES.

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

https://localhost:8443/owf/prefs/preference/com.company.widget/First%20President

#####Request Method:##### POST
Request Form Data _method:PUT
value: some value???? GIVE EXAMPLE?

#####Requirements:#####

Requirements: namespace, name and value

  • If name or namespace are null, it will fill them in with “undefined” and create a preference using that information.
  • If name or namespace are a non-null empty string, it will throw an HTML 404 error saying “The requested resource is not available.”
  • If value is null, it will throw an HTML error.

#####Response:##### If there is a preference matching the given namespace and name, it will change the value of the preference, if there is not it will create a new preference. Either way it will return the preference information, eg:

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

#####How to use it:##### This API alls a remote system to create or update preferences.


###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,
    value: “some value”
};

OWF.Preferences.setUserPreference(cfg);

###Resource Information## NOT SURE IF WE NEED THIS SECTION, if we do, it needs updated

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 400:”The requested entity failed to pass validation...on field 'path': rejected value [null]” Make sure that name is not an empty string.
HTTP status 400:”The requested entity failed to pass validation...on field 'value': rejected value [null]” Make sure that value is set to a non-null string.
HTTP Status 403: “Access to the specified resource has been forbidden.” Make sure namespace is not an empty string.