private OMElement resolveImports(
     OMElement grammarsElement, String wadlBaseUri, String wadlVersion) throws RegistryException {
   String wadlNamespace = grammarsElement.getNamespace().getNamespaceURI();
   Iterator<OMElement> grammarElements =
       grammarsElement.getChildrenWithName(new QName(wadlNamespace, "include"));
   while (grammarElements.hasNext()) {
     OMElement childElement = grammarElements.next();
     OMAttribute refAttr = childElement.getAttribute(new QName("href"));
     String importUrl = refAttr.getAttributeValue();
     if (importUrl.endsWith(".xsd")) {
       if (!importUrl.startsWith("http")) {
         if (registry.resourceExists(importUrl)) {
           continue;
         } else {
           if (wadlBaseUri != null) {
             importUrl = wadlBaseUri + importUrl;
           }
         }
       }
       String schemaPath = saveSchema(importUrl, wadlVersion);
       importedSchemas.add(schemaPath);
       refAttr.setAttributeValue(schemaPath);
       childElement.addAttribute(refAttr);
     }
   }
   return grammarsElement;
 }
  public void testWithoutTableParamsQuery() throws Exception {
    Resource r1 = registry.newResource();
    String r1Content = "this is r1 content";
    r1.setContent(r1Content.getBytes());
    r1.setDescription("production ready.");
    String r1Path = "/c1/r1";
    registry.put(r1Path, r1);

    Resource r2 = registry.newResource();
    String r2Content = "content for r2 :)";
    r2.setContent(r2Content);
    r2.setDescription("ready for production use.");
    String r2Path = "/c2/r2";
    registry.put(r2Path, r2);

    Resource r3 = registry.newResource();
    String r3Content = "content for r3 :)";
    r3.setContent(r3Content);
    r3.setDescription("only for government use.");
    String r3Path = "/c2/r3";
    registry.put(r3Path, r3);

    String sql1 =
        "SELECT REG_PATH_ID, REG_NAME FROM REG_RESOURCE, " + "REG_TAG WHERE REG_DESCRIPTION LIKE ?";
    Resource q1 = systemRegistry.newResource();
    q1.setContent(sql1);
    q1.setMediaType(RegistryConstants.SQL_QUERY_MEDIA_TYPE);
    q1.addProperty(
        RegistryConstants.RESULT_TYPE_PROPERTY_NAME, RegistryConstants.RESOURCES_RESULT_TYPE);
    systemRegistry.put("/qs/q1", q1);

    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("1", "%production%");
    Resource result = registry.executeQuery("/qs/q1", parameters);

    assertTrue(
        "Search with result type Resource should return a directory.",
        result instanceof org.wso2.carbon.registry.core.Collection);

    List<String> matchingPaths = new ArrayList<String>();
    String[] paths = (String[]) result.getContent();
    matchingPaths.addAll(Arrays.asList(paths));

    assertTrue("Path /c1/r1 should be in the results.", matchingPaths.contains("/c1/r1"));
    assertTrue("Path /c2/r2 should be in the results.", matchingPaths.contains("/c2/r2"));
  }
 public static SimulationResponse getSimulationResponse() {
   Map<String, List<String[]>> status = simulationService.getSimulationStatus();
   int entryCount = 0;
   Map<Integer, HandlerExecutionStatus> executionStatusMap =
       new HashMap<Integer, HandlerExecutionStatus>();
   if (status != null) {
     for (Map.Entry<String, List<String[]>> e : status.entrySet()) {
       if (e.getKey() != null && e.getValue() != null) {
         if (e.getValue().size() > 0) {
           for (String[] v : e.getValue()) {
             if (v != null && v.length == 2) {
               HandlerExecutionStatus executionStatus = new HandlerExecutionStatus();
               executionStatus.setHandlerName(e.getKey());
               executionStatus.setExecutionStatus(v[0]);
               int order = Integer.parseInt(v[1]);
               executionStatusMap.put(order, executionStatus);
               if (order > entryCount) {
                 entryCount = order;
               }
             }
           }
         }
       }
     }
   }
   List<HandlerExecutionStatus> executionStatusList = new LinkedList<HandlerExecutionStatus>();
   int i = 0;
   while (i < entryCount) {
     i++;
     HandlerExecutionStatus executionStatus = executionStatusMap.get(i);
     if (executionStatus != null) {
       executionStatusList.add(executionStatus);
     }
   }
   SimulationResponse response = new SimulationResponse();
   response.setStatus(
       executionStatusList.toArray(new HandlerExecutionStatus[executionStatusList.size()]));
   return response;
 }