Example #1
0
  @GET
  @Produces({"text/plain"})
  public String get(@QueryParam("outputDir") String outputDir) {
    if (outputDir == null) {
      outputDir = DEFAULT_OUTPUT_DIR;
    }
    String retVal = "Code Generation done at : " + outputDir;

    try {
      Domain entity = habitat.getComponent(Domain.class);
      Dom dom = Dom.unwrap(entity);
      DomDocument document = dom.document;
      ConfigModel rootModel = dom.document.getRoot().model;

      ResourcesGenerator resourcesGenerator = new TextResourcesGenerator(outputDir, habitat);
      resourcesGenerator.generateSingle(rootModel, document);
      resourcesGenerator.endGeneration();
    } catch (Exception ex) {
      Logger.getLogger(GeneratorResource.class.getName()).log(Level.SEVERE, null, ex);
      retVal =
          "Exception encountered during generation process: "
              + ex.toString()
              + "\nPlease look at server.log for more information.";
    }
    return retVal;
  }
Example #2
0
  @Test
  public void rawAttributeTest() throws NoSuchMethodException {

    String address = listener.getAddress();

    Dom raw = Dom.unwrap(listener);
    Attribute attr = raw.getProxyType().getMethod("getAddress").getAnnotation(Attribute.class);
    assertEquals(attr.defaultValue(), address);

    assertEquals(raw.attribute("address"), address);
    assertEquals(raw.rawAttribute("address"), address);
  }
Example #3
0
  @GET
  @Produces({"text/plain"})
  public String get() {
    //        status.append("\n------------------------");
    //        status.append("Status of Command usage\n");
    try {
      Domain entity = habitat.getComponent(Domain.class);
      Dom dom = Dom.unwrap(entity);
      DomDocument document = dom.document;
      ConfigModel rootModel = dom.document.getRoot().model;

      ResourcesGenerator resourcesGenerator = new NOOPResourcesGenerator(habitat);
      resourcesGenerator.generateSingle(rootModel, document);
      resourcesGenerator.endGeneration();
    } catch (Exception ex) {
      Logger.getLogger(GeneratorResource.class.getName()).log(Level.SEVERE, null, ex);
      // retVal = "Exception encountered during generation process: " + ex.toString() + "\nPlease
      // look at server.log for more information.";
    }

    status.append("\n------------------------");
    status.append("All Commands used in REST Admin:\n");
    for (String ss : commandsUsed) {
      status.append(ss + "\n");
    }

    listOfCommands();
    for (String ss : commandsUsed) {
      allCommands.remove(ss);
    }

    status.append("\n------------------------");
    status.append("Missing Commands not used in REST Admin:\n");

    for (String ss : allCommands) {
      if (hasTargetParam(ss)) {
        status.append(ss + "          has a target param " + "\n");
      } else {
        status.append(ss + "\n");
      }
    }
    status.append("\n------------------------");
    status.append("REST-REDIRECT Commands defined on ConfigBeans:\n");

    for (String ss : restRedirectCommands) {
      status.append(ss + "\n");
    }

    status.append("\n------------------------");
    status.append("Commands to Resources Mapping Usage in REST Admin:\n");

    for (String ss : commandsToResources.keySet()) {
      if (hasTargetParam(ss)) {
        status.append(ss + "   :::target:::   " + commandsToResources.get(ss) + "\n");
      } else {
        status.append(ss + "      :::      " + commandsToResources.get(ss) + "\n");
      }
    }
    status.append("\n------------------------");
    status.append("Resources with Delete Commands in REST Admin (not counting RESTREDIRECT:\n");
    for (String ss : resourcesToDeleteCommands.keySet()) {
      status.append(ss + "      :::      " + resourcesToDeleteCommands.get(ss) + "\n");
    }

    FileOutputStream f;
    try {
      f = new FileOutputStream(System.getProperty("user.home") + "/GlassFishI18NData.properties");
      propsI18N.store(f, "");
      f.close();

    } catch (Exception ex) {
      Logger.getLogger(StatusGenerator.class.getName()).log(Level.SEVERE, null, ex);
    }
    return status.toString();
  }