Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-4941

Add ModuleUtil.isOpenmrsVersionInVersions()

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Could
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Core 2.1.0
    • Component/s: None
    • Labels:
      None
    • Complexity:
      Low

      Description

      I see a lot of this:

      supportedOpenmrsVersions = subresourceAnnotation.supportedOpenmrsVersions();
      
      if (supportedOpenmrsVersions.length != 0) {
        boolean supported = false;
      					
        for (String supportedVersion : supportedOpenmrsVersions) {
          try {
          ModuleUtil.checkRequiredVersion(OpenmrsConstants.OPENMRS_VERSION_SHORT, supportedVersion);
            supported = true;
            continue;
            }
            catch (Exception e) {}
            }
      					
            if (!supported) {
              continue;
            }
      }
      

      in the REST module. (Forget about the bad practice of using try/catch for control flow; already opened an issue and am cleaning that up https://issues.openmrs.org/browse/RESTWS-609)

      see for example

      https://github.com/openmrs/openmrs-module-webservices.rest/blob/7324ff1ab44ff23a19032f70a3bc6f2da6df5438/omod-common/src/main/java/org/openmrs/module/webservices/rest/web/api/impl/RestServiceImpl.java#L243-L255

      There are at least 5 places in the REST module where one needs to check if a requiredVersion is in an array of supportedVersions.

      I therefore propose to add method

      ModuleUtil.isOpenmrsVersionInVersions(String[] versions)
      

      which does exactly that and is tested.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              teleivo Ivo Ulrich
              Reporter:
              teleivo Ivo Ulrich
              Designated Committer:
              Wyclif Luyima
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: