Package com.puppetlabs.geppetto.forge.model

Examples of com.puppetlabs.geppetto.forge.model.Metadata


      filter = moduleFileFilter;

    if(extractedFrom == null)
      extractedFrom = new File[1];

    Metadata md = null;
    for(MetadataExtractor extractor : getMetadataExtractors())
      if(extractor.canExtractFrom(moduleDirectory, filter)) {
        md = extractor.parseMetadata(moduleDirectory, includeTypesAndChecksums, filter, extractedFrom, result);
        break;
      }
View Full Code Here


  }

  public Metadata loadJSONMetadata(File jsonFile) throws IOException {
    Reader reader = new BufferedReader(new FileReader(jsonFile));
    try {
      Metadata md = gson.fromJson(reader, Metadata.class);
      return md;
    }
    finally {
      StreamUtil.close(reader);
    }
View Full Code Here

    }
  }

  @Override
  public Metadata loadModulefile(File moduleFile, Diagnostic diagnostic) throws IOException {
    Metadata metadata = new Metadata();
    ModuleUtils.parseModulefile(moduleFile, metadata, diagnostic);
    return metadata;
  }
View Full Code Here

    ModuleUtils.parseModulefile(moduleFile, metadata, diagnostic);
    return metadata;
  }

  public void saveJSONMetadata(Metadata md, File jsonFile) throws IOException {
    internalSaveJSONMetadata(new Metadata(md), jsonFile);
  }
View Full Code Here

      }

      checkCancel(subMon);

      // get metadata
      Metadata metadata;
      File[] extractionSource = new File[1];
      IFile metadataResource = project.getFile(METADATA_JSON_NAME);
      boolean metadataDerived = metadataResource.isDerived();

      if(metadataDerived) {
        try {
          // Delete this file. It will be recreated from other
          // sources.
          metadataResource.delete(true, subMon.newChild(1));
        }
        catch(CoreException e) {
          log.error("Unable to delete metadata.json", e);
        }
      }
      else {
        // The one that will be created should be considered to
        // be derived
        metadataDerived = !metadataResource.exists();
        subMon.worked(1);
      }

      Diagnostic diagnostic = new Diagnostic();
      try {
        // Load metadata, types, checksums etc.
        metadata = forge.createFromModuleDirectory(projectDir, true, null, extractionSource, diagnostic);
      }
      catch(Exception e) {
        createErrorMarker(project, "Can not parse Modulefile or other metadata source: " + e.getMessage(), null);
        if(log.isDebugEnabled())
          log.debug("Could not parse module description: '" + project.getName() + "'", e);
        return; // give up - errors have been logged.
      }

      if(metadata == null) {
        createErrorMarker(project, "Unable to find Modulefile or other metadata source", null);
        return;
      }

      // Find the resource used for metadata extraction
      File extractionSourceFile = extractionSource[0];
      IPath extractionSourcePath = Path.fromOSString(extractionSourceFile.getAbsolutePath());
      IFile moduleFile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(extractionSourcePath);

      createResourceMarkers(moduleFile, diagnostic);

      // sync version and name project data
      Version version = null;
      ModuleName moduleName = null;
      if(metadata != null) {
        version = metadata.getVersion();
        moduleName = metadata.getName();
      }

      if(version == null)
        version = Version.fromString("0.0.0");
View Full Code Here

    finally {
      reader.close();
    }

    try {
      Metadata md = new Metadata();
      StrictMetadataJsonParser mdParser = new StrictMetadataJsonParser(md);
      mdParser.parse(existingFile, swr.toString(), result);
      return md;
    }
    finally {
View Full Code Here

  private void geppettoValidation(Collection<File> moduleLocations, Diagnostic result) throws IOException {

    Collection<File> importedModuleLocations = null;
    List<Metadata> metadatas = new ArrayList<Metadata>();
    for(File moduleRoot : moduleLocations) {
      Metadata md = getModuleMetadata(moduleRoot, result);
      if(md != null)
        metadatas.add(md);
    }

    if(result.getSeverity() == Diagnostic.ERROR)
View Full Code Here

  public void publish(File moduleArchive, boolean dryRun, Diagnostic result) throws IOException {
    if(releaseService == null)
      throw new UnsupportedOperationException(
        "Unable to publish since no release service is configured. Was a serviceURL provided in the preferences?");

    Metadata metadata = forgeUtil.getMetadataFromPackage(moduleArchive);
    if(metadata == null)
      throw new ForgeException("No \"metadata.json\" found in archive: " + moduleArchive.getAbsolutePath());

    if(metadata.getName() == null)
      throw new ForgeException("The \"metadata.json\" found in archive: " + moduleArchive.getAbsolutePath() +
          " has no name");

    if(metadata.getVersion() == null)
      throw new ForgeException("The \"metadata.json\" found in archive: " + moduleArchive.getAbsolutePath() +
          " has no version");

    try {
      if(metadataRepo.resolve(metadata.getName(), metadata.getVersion()) != null)
        throw new AlreadyPublishedException("Module " + metadata.getName() + ':' + metadata.getVersion() +
            " has already been published");
    }
    catch(HttpResponseException e) {
      // A SC_NOT_FOUND can be expected and is OK.
      if(e.getStatusCode() != HttpStatus.SC_NOT_FOUND)
        throw new ForgeException("Unable to check module existence on the forge: " + e.getMessage());
    }

    if(dryRun) {
      result.addChild(new Diagnostic(INFO, PUBLISHER, "Module file " + moduleArchive.getName() +
          " would have been uploaded (but wasn't since this is a dry run)"));
      return;
    }

    InputStream gzInput = new FileInputStream(moduleArchive);
    try {
      ModuleName name = metadata.getName();
      releaseService.create(
        name.getOwner(), name.getName(), "Published using GitHub trigger", gzInput, moduleArchive.length());
      result.addChild(new Diagnostic(INFO, PUBLISHER, "Module file " + moduleArchive.getName() +
          " has been uploaded"));
    }
View Full Code Here

    return MODULEFILE_NAME;
  }

  @Override
  protected Metadata performMetadataExtraction(File existingFile, Diagnostic result) throws IOException {
    Metadata metadata = new Metadata();
    ModuleUtils.parseModulefile(existingFile, metadata, result);
    return metadata;
  }
View Full Code Here

      extractedFrom[0] = metadataFile;

    if(!canExtractFrom(moduleDirectory, filter))
      throw new FileNotFoundException(metadataFile.getAbsolutePath());

    Metadata md = performMetadataExtraction(metadataFile, result);
    if(md != null && !hasTypesAndProviders() && includeTypesAndChecksums) {
      md.setTypes(Types.loadTypes(new File(moduleDirectory, "lib/puppet"), filter));
      md.setChecksums(Checksums.loadChecksums(moduleDirectory, filter));
    }
    return md;
  }
View Full Code Here

TOP

Related Classes of com.puppetlabs.geppetto.forge.model.Metadata

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.