/**
   * Method to obtain a list of paths having resources of the given media type.
   *
   * @param registry the registry instance to run query on.
   * @param mediaType the media type.
   * @return an array of resource paths.
   * @throws RegistryException if the operation failed.
   */
  public static String[] getResultPaths(Registry registry, String mediaType)
      throws RegistryException {
    String[] result;
    String[] paginatedResult;
    try {
      Map<String, String> parameter = new HashMap<String, String>();
      parameter.put("1", mediaType);
      parameter.put(
          "query",
          "SELECT DISTINCT REG_PATH_ID, REG_NAME FROM REG_RESOURCE WHERE REG_MEDIA_TYPE=?");
      result = (String[]) registry.executeQuery(null, parameter).getContent();
      if (result == null || result.length == 0) {
        return new String[0];
      }
      result = removeMountPaths(result, registry);
      MessageContext messageContext = MessageContext.getCurrentMessageContext();
      if (PaginationUtils.isPaginationAnnotationFound("getPaginatedGovernanceArtifacts")
          && ((messageContext != null && PaginationUtils.isPaginationHeadersExist(messageContext))
              || PaginationContext.getInstance() != null)) {

        int rowCount = result.length;
        PaginationContext paginationContext;
        try {
          if (messageContext != null) {
            PaginationUtils.setRowCount(messageContext, Integer.toString(rowCount));
            paginationContext = PaginationUtils.initPaginationContext(messageContext);
          } else {
            paginationContext = PaginationContext.getInstance();
          }

          int start = paginationContext.getStart();
          int count = paginationContext.getCount();

          int startIndex;
          if (start == 1) {
            startIndex = 0;
          } else {
            startIndex = start;
          }
          if (rowCount < start + count) {
            paginatedResult = new String[rowCount - startIndex];
            System.arraycopy(result, startIndex, paginatedResult, 0, (rowCount - startIndex));
          } else {
            paginatedResult = new String[count];
            System.arraycopy(result, startIndex, paginatedResult, 0, count);
          }
          return paginatedResult;

        } finally {
          PaginationContext.destroy();
        }
      }
    } catch (RegistryException e) {
      String msg = "Error in getting the result for media type: " + mediaType + ".";
      log.error(msg, e);
      throw new RegistryException(msg, e);
    }
    return result;
  }