1 /**
  2  * @fileOverview JavaScript representation of the Finesse ClientLog object
  3  *
  4  * @name ClientLog
  5  * @requires finesse.clientservices.ClientServices
  6  * @requires Class
  7  * @requires finesse.FinesseBase
  8  * @requires finesse.restservices.RestBase
  9  */
 10 
 11 var finesse = finesse || {};
 12 finesse.restservices = finesse.restservices || {};
 13 
 14 /** @private */
 15 finesse.restservices.ClientLog = finesse.restservices.RestBase.extend(/** @lends finesse.restservices.ClientLog.prototype */{    
 16     /**
 17      * @private
 18      * Returns whether this object supports transport logs
 19      */
 20     doNotLog : true,
 21     
 22     explicitSubscription : true,
 23     
 24     /**
 25      * @class
 26      * JavaScript representation of a ClientLog object. Also exposes methods to operate
 27      * on the object against the server.
 28      *
 29      * @param {Object} options
 30      *     An object with the following properties:<ul>
 31      *         <li><b>id:</b> The id of the object being constructed</li>
 32      *         <li><b>onLoad(this): (optional)</b> when the object is successfully loaded from the server</li>
 33      *         <li><b>onChange(this): (optional)</b> when an update notification of the object is received</li>
 34      *         <li><b>onAdd(this): (optional)</b> when a notification that the object is created is received</li>
 35      *         <li><b>onDelete(this): (optional)</b> when a notification that the object is deleted is received</li>
 36      *         <li><b>onError(rsp): (optional)</b> if loading of the object fails, invoked with the error response object:<ul>
 37      *             <li><b>status:</b> {Number} The HTTP status code returned</li>
 38      *             <li><b>content:</b> {String} Raw string of response</li>
 39      *             <li><b>object:</b> {Object} Parsed object of response</li>
 40      *             <li><b>error:</b> {Object} Wrapped exception that was caught:<ul>
 41      *                 <li><b>errorType:</b> {String} Type of error that was caught</li>
 42      *                 <li><b>errorMessage:</b> {String} Message associated with error</li>
 43      *             </ul></li>
 44      *         </ul></li>
 45      *         <li><b>parentObj: (optional)</b> The parent object</li></ul>
 46      * @constructs finesse.restservices.MediaPropertiesLayout
 47      **/
 48     init: function (options) {
 49         this._super({
 50             id: "", 
 51             data: {clientLog : null},
 52             onAdd: options.onAdd,
 53             onChange: options.onChange,
 54             onLoad: options.onLoad,
 55             onError: options.onError,
 56             parentObj: options.parentObj
 57             });
 58     },
 59 
 60     /**
 61      * @private
 62      * Gets the REST class for the current object - this is the ClientLog object.
 63      */
 64     getRestClass: function () {
 65         return finesse.restservices.ClientLog;
 66     },
 67 
 68     /**
 69      * @private
 70      * Gets the REST type for the current object - this is a "ClientLog".
 71      */
 72     getRestType: function ()
 73     {
 74         return "ClientLog";
 75     },
 76     
 77     /**
 78      * overloading this to return URI
 79      */
 80     getXMPPNodePath: function () {
 81         return this.getRestUrl();
 82     },
 83        
 84     /**
 85      * @private
 86      * Invoke a request to the server given a content body and handlers.
 87      *
 88      * @param {Object} contentBody
 89      *     A JS object containing the body of the action request.
 90      * @param {Object} handlers
 91      *     An object containing the following (optional) handlers for the request:<ul>
 92      *         <li><b>success(rsp):</b> A callback function for a successful request to be invoked with the following
 93      *         response object as its only parameter:<ul>
 94      *             <li><b>status:</b> {Number} The HTTP status code returned</li>
 95      *             <li><b>content:</b> {String} Raw string of response</li>
 96      *             <li><b>object:</b> {Object} Parsed object of response</li></ul>
 97      *         <li>A error callback function for an unsuccessful request to be invoked with the
 98      *         error response object as its only parameter:<ul>
 99      *             <li><b>status:</b> {Number} The HTTP status code returned</li>
100      *             <li><b>content:</b> {String} Raw string of response</li>
101      *             <li><b>object:</b> {Object} Parsed object of response (HTTP errors)</li>
102      *             <li><b>error:</b> {Object} Wrapped exception that was caught:<ul>
103      *                 <li><b>errorType:</b> {String} Type of error that was caught</li>
104      *                 <li><b>errorMessage:</b> {String} Message associated with error</li>
105      *             </ul></li>
106      *         </ul>
107      */
108     sendLogs: function (contentBody, handlers) {
109         // Protect against null dereferencing of options allowing its
110         // (nonexistant) keys to be read as undefined
111         handlers = handlers || {};
112 
113         this.restRequest(this.getRestUrl(), {
114             method: 'POST',
115             //success: handlers.success,
116             error: handlers.error,
117             content: contentBody
118         });
119     }
120 });