Uploaded image for project: 'Service Packs and Hot Fixes'
  1. Service Packs and Hot Fixes
  2. MNT-15774

CLONE - REST Processes and Tasks API for parameters/variables allowed MATCHES operator, operator is not case-insensitive

    Details

      Description

      According to http://docs.alfresco.com/5.0/pra/1/concepts/act-processes-get-processes.html there is a sample filtering of data:

      where=( startUserId='kermit' AND businessKey='55' AND variables/nameB MATCHES('elmo%') ).

      This is case sensitive, request is to make the MATCHES operator case insensitive.
      This would be change applicable to any REST api's that afford the use of the MATCHES operator for parameters which are string values.

      Replication steps

      • Using Share UI, start a workflow (this example I only had one in so simple test)
      • Using basic FF RestClient
      • get a process or task to test with for example:
      GET http://localhost:8080/alfresco/api/-default-/public/workflow/versions/1/processes?where=(includeVariables=true)
      

      results show

      {"list":{"pagination":{"count":1,"hasMoreItems":false,"totalItems":1,"skipCount":0,"maxItems":100},"entries":[{"entry":{"processDefinitionId":"activitiReview:1:8","startUserId":"admin","startActivityId":"start","startedAt":"2015-08-18T17:47:17.207+0000","id":"101","completed":false,"processVariables":[{"name":"bpm_package","type":"bpm:workflowPackage","value":"workspace://SpacesStore/f686ca19-6403-4fcc-8e0a-496574d32af5"},{"name":"bpm_assignee","type":"cm:person","value":"admin"},{"name":"bpm_packageActionGroup","type":"d:text","value":"add_package_item_actions"},{"name":"bpm_workflowDescription","type":"d:text","value":"Test workflow api calls review and approve"},{"name":"bpm_reassignable","type":"d:boolean","value":true},{"name":"bpm_packageItemActionGroup","type":"d:text","value":"start_package_item_actions"},{"name":"bpm_priority","type":"d:int","value":2},{"name":"companyhome","type":"d:noderef","value":"workspace://SpacesStore/57a26610-d42e-4d13-9a60-24cdce1d5991"},{"name":"initiator","type":"d:noderef","value":"admin"},{"name":"_startTaskCompleted","type":"d:datetime","value":"2015-08-18T17:47:17.382+0000"},{"name":"bpm_percentComplete","type":"d:int","value":0},{"name":"bpm_sendEMailNotifications","type":"d:boolean","value":false},{"name":"bpm_description","type":"d:text","value":"Test workflow api calls review and approve"},{"name":"bpm_workflowPriority","type":"d:int","value":2},{"name":"bpm_hiddenTransitions","type":"d:text","value":""},{"name":"workflowinstanceid","type":"d:text","value":"activiti$101"},{"name":"initiatorhome","type":"d:noderef","value":"workspace://SpacesStore/57a26610-d42e-4d13-9a60-24cdce1d5991"},{"name":"bpm_workflowDueDate","type":"d:date","value":null},{"name":"cm_name","type":"d:text","value":"Task"},{"name":"bpm_status","type":"d:text","value":"Not Yet Started"},{"name":"cancelled","type":"d:boolean","value":false},{"name":"wf_reviewOutcome","type":"d:text","value":"Approve"}],"processDefinitionKey":"activitiReview"}}]}}
      
      • Using one of the string variables from the "processVariables" in json response to specifically search for case match
        (if using tasks you can use any of the parameters that allows MATCHES operator):
      GET http://localhost:8080/alfresco/api/-default-/public/workflow/versions/1/processes?where=(variables/bpm_workflowDescription MATCHES ('Test workflow api calls review and approve'))
      

      Result:

      {"list":{"pagination":{"count":1,"hasMoreItems":false,"totalItems":1,"skipCount":0,"maxItems":100},"entries":[{"entry":{"processDefinitionId":"activitiReview:1:8","startUserId":"admin","startActivityId":"start","startedAt":"2015-08-18T17:47:17.207+0000","id":"101","completed":false,"processDefinitionKey":"activitiReview"}}]}}
      
      • Search the same "processVariables" test case insensitive match:
      GET http://localhost:8080/alfresco/api/-default-/public/workflow/versions/1/processes?where=(variables/bpm_workflowDescription MATCHES ('test workflow api calls review and approve'))
      

      result

      {"list":{"pagination":{"count":0,"hasMoreItems":false,"totalItems":0,"skipCount":0,"maxItems":100},"entries":[]}}
      

      Expected Behaviour

      • Regardless of case, the MATCHES clause should match

      [MER 10/03/2016 - Please note that this expected behaviour is not correct. The expected behaviour is that the query is case sensitive. Instead a new prefix was added to the query to enable a case insensitive search. Please see the linked issue for further details]

      Actual Behaviour

      • MATCHES clause is case sensitive

      Additional Information

      • MATCHES can only be used for string values

      Ref:

      Alex Strachan noted that when looking through the code, the class org.alfresco.rest.workflow.api.impl.ProcessesImpl calls a generic class called WhereClauseParser(). This parser class seems to do a direct comparison of objects (there is no toLower() or anything called before comparisons).

      • /root/projects/remote-api/source/java/org/alfresco/rest/workflow/api/impl/ProcessesImpl.java
      • /root/projects/remote-api/source/generated/org/alfresco/rest/antlr/WhereClauseParser.java

        Attachments

          Issue Links

            Structure

              Activity

                People

                • Assignee:
                  closedbugs Closed Bugs
                  Reporter:
                  hseritt Harlin Seritt [X] (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  11 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - Not Specified
                    Not Specified
                    Remaining:
                    Remaining Estimate - 0 minutes
                    0m
                    Logged:
                    Time Spent - 3 hours, 30 minutes
                    3h 30m

                      Structure Helper Panel