Uploaded image for project: 'REST Client'
  1. REST Client
  2. MGNLRESTCL-73

RestClient should not be modified by usages

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • 2.0
    • None
    • None
    • None
    • Declarative REST 10, Declarative REST 11
    • 3

      If a developer changes body of a request on a RestCall in a usage, it should not have an effect on the client itself, or other calls of the rest client - the changes to the body should only affect that specific one call, on that specific client.

      (I have not tested, but the problem may apply to other aspects of a request such as headers, parameters)

       I have only tested this one example - but I am wondering how this relates to usages in different locations in java code or also in restfn in templates.

      // code placeholder
      //JS model
      var restClient = restClientFactory.createClient(restClientRegistry.getProvider("posts").get());   var restCall = restClient.getRestClientDefinition().getRestCalls().get("create")
      
      restCall.getHeaders().put("Content-Type", "application/json; charset=UTF-8")
      restCall.setBody({   title: title,   body: body})
      
      var result1 =  JSON.parse(restClient.invoke(restCall))  
      
      // This call will have the body set above! Not good! 
      
      var restCall2 = restClient.getRestClientDefinition().getRestCalls().get("create")
      var result2 =  JSON.parse(restClient.invoke(restCall2))  
      
      // This call will have the body set above! Not good! 
      
      var restClient3 = restClientFactory.createClient(restClientRegistry.getProvider("posts").get());         
      
      var restCall3 = restClient3.getRestClientDefinition().getRestCalls().get("create")var result3 =  JSON.parse(restClient3.invoke(restCall3))
      

      Above example adopted from:  https://git.magnolia-cms.com/users/jfranco/repos/declarative-rest/browse/declarative-rest-demo/src/main/resources/declarative-rest-demo/templates/components/rest-model.js?at=refs%2Fheads%2Fjorge%2FduplicatePosts

       

       

       

        Acceptance criteria

              dai.ha Dai Ha
              czimmermann Christopher Zimmermann
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Task DoD

                    Estimated:
                    Original Estimate - Not Specified
                    Not Specified
                    Remaining:
                    Remaining Estimate - 0d
                    0d
                    Logged:
                    Time Spent - 5.75d
                    5.75d