Package com.puppetlabs.geppetto.diagnostic

Examples of com.puppetlabs.geppetto.diagnostic.Diagnostic


      if(diag.getSeverity() >= Diagnostic.WARNING)
        DiagnosticAnnotation.add(diag, model, document);
  }

  void validate() {
    Diagnostic chain = new Diagnostic();
    editor.getModel().setDocument(editor.getDocument(), editor.getPath(), chain);
    updateDiagnosticAnnotations(chain);
    if(isActive())
      editor.markStale();
  }
View Full Code Here


      List<String> result = Lists.newArrayList();

      // parse the "Modulefile/metadata.json" and get full name and version, use this as name of target entry
      // TODO: Improve this to report diagnostics
      try {
        Diagnostic diag = new Diagnostic();
        Metadata metadata = forge.createFromModuleDirectory(moduleDir, false, null, null, diag);
        if(metadata != null) {
          for(Dependency d : metadata.getDependencies()) {
            IProject best = getBestMatchingProject(d);
            if(best != null)
View Full Code Here

  @Override
  protected void invoke(Diagnostic result) throws Exception {
    Collection<File> moduleRoots = findModuleRoots();
    if(moduleRoots.isEmpty()) {
      result.addChild(new Diagnostic(ERROR, PACKAGE, "No modules found in repository"));
      return;
    }

    File buildDir = getBuildDir();
    buildDir.mkdirs();
    if(moduleRoots.size() == 1) {
      MavenProject project = getProject();
      File moduleRoot = moduleRoots.iterator().next();
      Metadata[] resultingMetadata = new Metadata[1];
      byte[][] resultingMD5 = new byte[1][];
      project.getArtifact().setFile(buildForge(moduleRoot, buildDir, resultingMetadata, resultingMD5, result));

      Artifact pmriArtifact = repositorySystem.createArtifact(
        project.getGroupId(), project.getArtifactId(), project.getVersion(), "compile", "pmri");

      PuppetModuleReleaseInfo pmri = new PuppetModuleReleaseInfo();
      pmri.setMetadata(resultingMetadata[0]);
      pmri.populate(moduleRoot);

      File pmriFile = new File(buildDir, "release.pmri");
      OutputStream out = new FileOutputStream(pmriFile);
      try {
        Writer writer = new BufferedWriter(new OutputStreamWriter(out, Charsets.UTF_8));
        getGson().toJson(pmri, writer);
        writer.flush();
      }
      finally {
        out.close();
      }
      pmriArtifact.setFile(pmriFile);
      pmriArtifact.setResolved(true);
      project.addAttachedArtifact(pmriArtifact);
    }
    else {
      File builtModules = new File(buildDir, "builtModules");
      if(!(builtModules.mkdir() || builtModules.isDirectory())) {
        result.addChild(new Diagnostic(ERROR, PACKAGE, "Unable to create directory" + builtModules.getPath()));
        return;
      }
      for(File moduleRoot : moduleRoots)
        buildForge(moduleRoot, builtModules, null, null, result);
    }
View Full Code Here

  }

  protected boolean isValidModule(File moduleDirectory, FileFilter filter) {
    Metadata md;
    try {
      md = forge.createFromModuleDirectory(moduleDirectory, false, filter, null, new Diagnostic());
      return md != null && md.getName() != null && md.getName().getOwner() != null &&
          md.getName().getName() != null && md.getVersion() != null;
    }
    catch(IOException e) {
    }
View Full Code Here

            result.taskDone();
            noPublishingMade = false;
            continue;
          }
          catch(AlreadyPublishedException e) {
            result.addChild(new Diagnostic(Diagnostic.WARNING, PUBLISHER, e.getMessage()));
            result.taskDone();
            continue;
          }
          catch(ForgeException e) {
            result.addChild(new Diagnostic(Diagnostic.ERROR, PUBLISHER, e.getMessage()));
          }
          catch(Exception e) {
            result.addChild(new ExceptionDiagnostic(
              Diagnostic.ERROR, PUBLISHER, "Unable to publish module " + builtModule.getName(), e));
          }
          return;
        }

        if(noPublishingMade) {
          result.addChild(new Diagnostic(
            Diagnostic.INFO, PUBLISHER, "All modules have already been published at their current version"));
        }
      }
      finally {
        result.done();
View Full Code Here

      Forge forge = getEditor().getForge();

      Map<String, VersionedName> modules = new HashMap<String, VersionedName>();
      IProject current = getCurrentProject();
      Diagnostic chain = new Diagnostic();
      ModuleName always = null;
      if(toBeEdited != null)
        try {
          always = ModuleName.fromString(toBeEdited);
        }
View Full Code Here

    modules.add(new ValidationModule());
    modules.add(getCommonModule());
  }

  public void execute() throws MojoExecutionException, MojoFailureException {
    Diagnostic diagnostic = new LoggingDiagnostic(getLogger());
    try {
      List<Module> modules = new ArrayList<Module>();
      addModules(diagnostic, modules);
      if(diagnostic.getSeverity() <= Diagnostic.WARNING) {
        injector = Guice.createInjector(modules);
        invoke(diagnostic);
      }
    }
    catch(JsonParseException e) {
      throw new MojoFailureException(getActionName() + " failed: Invalid Json: " + e.getMessage(), e);
    }
    catch(RuntimeException e) {
      throw e;
    }
    catch(Exception e) {
      throw new MojoFailureException(getActionName() + " failed: " + e.getMessage(), e);
    }
    if(diagnostic.getSeverity() == Diagnostic.ERROR) {
      Exception e = diagnostic.getException();
      if(e == null)
        throw new MojoFailureException(diagnostic.getErrorText());
      throw new MojoFailureException(diagnostic.getErrorText(), e);
    }
  }
View Full Code Here

   */
  @Test
  public void validateDuplicateRoleDifferentEnv() throws Exception {
    File root = TestDataProvider.getTestFile(new Path("testData/testRoles3/"));
    ValidationService vs = getValidationService();
    Diagnostic chain = new Diagnostic();
    ValidationOptions options = getValidationOptions();
    options.setCheckLayout(true);
    options.setCheckModuleSemantics(true);
    options.setCheckReferences(true);
    options.setFileType(FileType.PUPPET_ROOT);
View Full Code Here

   */
  @Test
  public void validateDuplicateRoleDuplicateRole() throws Exception {
    File root = TestDataProvider.getTestFile(new Path("testData/testRoles3/"));
    ValidationService vs = getValidationService();
    Diagnostic chain = new Diagnostic();
    ValidationOptions options = getValidationOptions();
    options.setCheckLayout(true);
    options.setCheckModuleSemantics(true);
    options.setCheckReferences(true);
    options.setFileType(FileType.PUPPET_ROOT);
    // options.setSearchPath("modules/*:roles/production/*");
    vs.validate(chain, root, options, null, SubMonitor.convert(null));

    // Without constraint that only things on path are validated - there should be two redefinition errors
    //
    List<Diagnostic> children = chain.getChildren();
    int count = 0;
    for(Diagnostic d : children)
      if(d.getSeverity() >= Diagnostic.ERROR) {
        assertEquals(IValidationConstants.ISSUE__MODULEFILE_REDEFINITION, d.getIssue());
        ++count;
View Full Code Here

   */
  @Test
  public void validateNodes() throws Exception {
    File root = TestDataProvider.getTestFile(new Path("testData/testRoles/"));
    ValidationService vs = getValidationService();
    Diagnostic chain = new Diagnostic();
    ValidationOptions options = getValidationOptions();
    options.setCheckLayout(true);
    options.setCheckModuleSemantics(true);
    options.setCheckReferences(true);
    options.setFileType(FileType.PUPPET_ROOT);
View Full Code Here

TOP

Related Classes of com.puppetlabs.geppetto.diagnostic.Diagnostic

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.