Ignore:
Timestamp:
08/20/13 13:54:43 (11 years ago)
Author:
mwindhouwer
Message:

Made the ISOcat API more RESTful:

  • create resources using POST
  • update resources using PUT

One outlier: we use POST for creating users eventhough the client in this case specifies the full resource URL
Other outliers: in many cases we allow a dummy 0 for a POST call, e.g., POST /dcs/0 to create a new DCS

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cats/ISOcat/trunk/mod-ISOcat-interface-gi/interface/JSXAPPS/ISOcat/js/org/isocat/data/User.js

    r2288 r3447  
    119119                        var uri = "http://isocat:8080/isocat/rest/user/"+escape(this._login)+"/session/0";
    120120                        this._prefix = jsx3.xml.CDF.getKey();
    121                         req = jsx3.net.Request.open("PUT",uri,false,this._prefix+"-"+this._login,this._password);
     121                        req = jsx3.net.Request.open("POST",uri,false,this._prefix+"-"+this._login,this._password);
    122122                        org.isocat.data.User.log.info("uri["+uri+"] ["+this._prefix+"-"+this._login+":"+this._password+"]");
    123                         req.send("<session/>");// PUT an empty session document
     123                        req.send("<session/>");// POST an empty session document
    124124                } else if (this._method == "shib") {
    125125                        var uri = "http://isocat:8080/isocat/rest/shib/sso";
     
    181181                        var uri = "http://isocat:8080/isocat/rest/user/"+escape(this._login)+".xml";
    182182                       
    183                         //req = new jsx3.net.Request().open("POST",uri,false,this._login,this._password);
    184                         req = new jsx3.net.Request().open("POST",uri,false);
     183                        //req = new jsx3.net.Request().open("PUT",uri,false,this._login,this._password);
     184                        req = new jsx3.net.Request().open("PUT",uri,false);
    185185                        req.setRequestHeader("Content-Type","application/xml");// IE doesn't set this automagically (FF does), and otherwise NK won't pass it on to the ISOcat accessors
    186186                        req.send(res.toString());
     
    265265        User_prototype.lockDC = function(id) {
    266266                var uri = "http://isocat:8080/isocat/rest/user/"+escape(this._login)+"/session/"+this._session.id+"/lock/dc/"+id;
    267                 org.isocat.data.User.log.info("request[PUT] uri["+uri+"]");
    268                 var req = jsx3.net.Request.open("PUT",uri,false);
    269                 req.send("<lock/>");// PUT an empty lock document
    270                 org.isocat.data.User.log.info("request[PUT] uri["+uri+"] status["+req.getStatus()+"] response["+req.getResponseText()+"]["+req.getResponseXML()+"]");
     267                org.isocat.data.User.log.info("request[POST] uri["+uri+"]");
     268                var req = jsx3.net.Request.open("POST",uri,false);
     269                req.send("<lock/>");// POST an empty lock document
     270                org.isocat.data.User.log.info("request[POST] uri["+uri+"] status["+req.getStatus()+"] response["+req.getResponseText()+"]["+req.getResponseXML()+"]");
    271271                if (req.getStatus()==201) {
    272272                        // acquired the DC lock
Note: See TracChangeset for help on using the changeset viewer.